-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
cache the storage info for 5 min #3214
Conversation
Signed-off-by: Robin Appelman <robin@icewind.nl>
@icewind1991, thanks for your PR! By analyzing the history of the files in this pull request, we identified @MorrisJobke, @blizzz and @nickvergessen to be potential reviewers. |
Does that also mean that when you are uploading still the old storage info is used and you maybe could upload more than allowed? |
Free space is still checked on upload |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and works 👍
@@ -533,6 +540,11 @@ public static function findBinaryPath($program) { | |||
* @throws \OCP\Files\NotFoundException | |||
*/ | |||
public static function getStorageInfo($path, $rootInfo = null) { | |||
$memcache = \OC::$server->getMemCacheFactory()->create('storageInfo'); | |||
$cached = $memcache->get($rootInfo ? '__root__' : $path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memcached has a limit of 250 chars. So you need to sha1 or something the path here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
Signed-off-by: Robin Appelman <robin@icewind.nl>
Current coverage is 54.02% (diff: 84.21%)@@ master #3214 diff @@
==========================================
Files 1298 1298
Lines 80110 80482 +372
Methods 7910 7953 +43
Messages 0 0
Branches 1248 1248
==========================================
+ Hits 43239 43477 +238
- Misses 36871 37005 +134
Partials 0 0
|
$cached = $memcache->get($cacheKey); | ||
if (is_array($cached)) { | ||
return $cached; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not unique across users. So this exposed the storage info of the user in the cache to all other users. Therefore I reverted this. #3515
Please come up with a proper implementation. And also take care of invalidate the cache when setting the quota.
For most external storages getting the storage info is expense
Since the storage info doesn't change often we cache it for 5 min
comparison when using fed. share