-
Notifications
You must be signed in to change notification settings - Fork 10
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
Change cache key to account for key's modification time. #2
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,21 +37,20 @@ def proxy_s3_bucket(self, environ, start_response): | |
|
||
def fetch_s3_object(self, bucket, key): | ||
m = hashlib.md5() | ||
m.update(bucket+key) | ||
cache_key = m.hexdigest() | ||
|
||
conn = boto.connect_s3() | ||
|
||
b = conn.get_bucket(bucket) | ||
k = b.get_key(key) | ||
if k == None: | ||
return None | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should |
||
m.update(bucket+key+k.last_modified) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. spaces around |
||
cache_key=m.hexdigest() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. space around |
||
if cache_key in self.cache: | ||
self.logger.debug('cache hit for %s' % cache_key) | ||
return self.cache[cache_key] | ||
else: | ||
self.logger.debug('cache miss for %s' % cache_key) | ||
|
||
b = conn.get_bucket(bucket) | ||
k = b.get_key(key) | ||
if k: | ||
obj = k.get_contents_as_string() | ||
self.cache[cache_key] = obj | ||
return obj | ||
else: | ||
return None | ||
obj = k.get_contents_as_string() | ||
self.cache[cache_key] = obj | ||
return obj |
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.