Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FileStorage: Create subdirs when using the method derive #33

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

radoslavius
Copy link

I do not know if it was the intention, but this behavior seems to me better. Especially if there is a large number of cached files.

@radoslavius radoslavius changed the title Create subdirs when using the method derive FileStorage: Create subdirs when using the method derive Oct 21, 2015
@@ -143,7 +143,7 @@ public function lock($key)
{
$cacheFile = $this->getCacheFile($key);
if ($this->useDirs && !is_dir($dir = dirname($cacheFile))) {
@mkdir($dir); // @ - directory may already exist
@mkdir($dir, 0777, true); // @ - directory may already exist
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not thread safe.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@milo What problem it can cause?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dg Let's say only a dir/ exists and 1st thread is creating dir/aaa/bbb/ and 2nd dir/aaa/ccc/. When they start in the same time, 1st creates dir/aaa/ and 2nd tries too. 1st is success and continues to create dir/aaa/bbb/ but 2nd fails and ends, so dir/aaa/ccc/ does not exist.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recalled nette/nette@0e23c0a

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@milo thanx!

Btw, FileStorage is using only one level of directories, isn't it? So this PR is not needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dg Imho, purpose is that $cache->derive('a')->derive('b')->derive('c')->save('key', 'val'); will create tmp/_a/_b/_c, now it creates tmp/_%00a%00b%00c.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I see!

@dg dg force-pushed the master branch 3 times, most recently from 2f8f6fb to 8c9cca3 Compare April 21, 2016 13:13
@dg dg force-pushed the master branch 6 times, most recently from 0aed862 to a0c400e Compare May 2, 2016 20:25
@dg dg force-pushed the master branch 3 times, most recently from 54c618b to 62a27d9 Compare May 19, 2016 00:29
@dg dg force-pushed the master branch 2 times, most recently from ec9e432 to e07955b Compare June 14, 2016 14:24
@dg dg force-pushed the master branch 3 times, most recently from 492413c to b0b475e Compare January 9, 2017 20:11
@dg dg force-pushed the master branch 4 times, most recently from 6037e83 to 1fe69cc Compare January 13, 2017 07:34
@dg dg force-pushed the master branch 4 times, most recently from 6df4f89 to 30051c1 Compare January 23, 2017 21:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants