From 763b40a31c0b8ec7de2c69a00ad6c84805778ac1 Mon Sep 17 00:00:00 2001 From: Danilo Poccia Date: Tue, 20 May 2014 10:16:01 +0200 Subject: [PATCH] Get key cache optimization. --- yas3fs/__init__.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/yas3fs/__init__.py b/yas3fs/__init__.py index 458d2d8..75acdba 100755 --- a/yas3fs/__init__.py +++ b/yas3fs/__init__.py @@ -389,8 +389,8 @@ def rename(self, path, new_path): self.entries[new_path] = self.entries[path] self.lru.append(new_path) self.lru.delete(path) - del self.entries[path] - self.reset(path) # I need 'deleted' + del self.entries[path] # So that the next reset doesn't delete the entry props + self.reset(path) # I need 'deleted' ### Something better ??? def get(self, path, prop=None): self.lru.move_to_the_tail(path) # Move to the tail of the LRU cache try: @@ -1158,13 +1158,13 @@ def get_key(self, path, cache=True): if key: logger.debug("get_key from cache '%s'" % (path)) return key - look_on_S3 = True - if path != '/': - (parent_path, file) = os.path.split(path) - dirs = self.cache.get(parent_path, 'readdir') - if dirs and file not in dirs: - look_on_S3 = False # We know it's not there - if look_on_S3: + look_on_S3 = True + if path != '/': + (parent_path, file) = os.path.split(path) + dirs = self.cache.get(parent_path, 'readdir') + if dirs and file not in dirs: + look_on_S3 = False # We know it's not there + if not cache or look_on_S3: logger.debug("get_key from S3 #1 '%s'" % (path)) key = self.s3_bucket.get_key(self.join_prefix(path)) if not key and path != '/':