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

cache the storage info for 5 min #3214

Merged
merged 2 commits into from
Jan 24, 2017
Merged

cache the storage info for 5 min #3214

merged 2 commits into from
Jan 24, 2017

Conversation

icewind1991
Copy link
Member

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

Signed-off-by: Robin Appelman <robin@icewind.nl>
@icewind1991 icewind1991 added the 3. to review Waiting for reviews label Jan 23, 2017
@icewind1991 icewind1991 added this to the Nextcloud 12.0 milestone Jan 23, 2017
@mention-bot
Copy link

@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.

@MorrisJobke
Copy link
Member

Does that also mean that when you are uploading still the old storage info is used and you maybe could upload more than allowed?

@icewind1991
Copy link
Member Author

Free space is still checked on upload

Copy link
Member

@MorrisJobke MorrisJobke left a 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);
Copy link
Member

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.

Copy link
Member Author

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>
@codecov-io
Copy link

Current coverage is 54.02% (diff: 84.21%)

Merging #3214 into master will increase coverage by 0.04%

@@             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          
Diff Coverage File Path
•••••••• 84% lib/private/legacy/helper.php

Powered by Codecov. Last update 5d48647...cbc18b7

@icewind1991 icewind1991 merged commit f55260b into master Jan 24, 2017
@icewind1991 icewind1991 deleted the cache-storage-info branch January 24, 2017 12:49
$cached = $memcache->get($cacheKey);
if (is_array($cached)) {
return $cached;
}
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 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants