Standardize cache_key generation

This commit is contained in:
Ruud
2013-09-03 12:48:24 +02:00
parent 97c456c9e1
commit 6af00bf026
3 changed files with 9 additions and 8 deletions
+4 -3
View File
@@ -259,8 +259,8 @@ class Plugin(object):
def getCache(self, cache_key, url = None, **kwargs):
cache_key = md5(ss(cache_key))
cache = Env.get('cache').get(cache_key)
cache_key_md5 = md5(ss(cache_key))
cache = Env.get('cache').get(cache_key_md5)
if cache:
if not Env.get('dev'): log.debug('Getting cache %s', cache_key)
return cache
@@ -284,8 +284,9 @@ class Plugin(object):
return ''
def setCache(self, cache_key, value, timeout = 300):
cache_key_md5 = md5(ss(cache_key))
log.debug('Setting cache %s', cache_key)
Env.get('cache').set(cache_key, value, timeout)
Env.get('cache').set(cache_key_md5, value, timeout)
return value
def createNzbName(self, data, movie):
+2 -2
View File
@@ -35,7 +35,7 @@ class Suggestion(Plugin):
suggestions = cached_suggestion
else:
suggestions = fireEvent('movie.suggest', movies = movies, ignore = ignored, single = True)
self.setCache(md5(ss('suggestion_cached')), suggestions, timeout = 6048000) # Cache for 10 weeks
self.setCache('suggestion_cached', suggestions, timeout = 6048000) # Cache for 10 weeks
return {
'success': True,
@@ -87,6 +87,6 @@ class Suggestion(Plugin):
if suggestions:
new_suggestions.extend(suggestions)
self.setCache(md5(ss('suggestion_cached')), new_suggestions, timeout = 6048000)
self.setCache('suggestion_cached', new_suggestions, timeout = 6048000)
return new_suggestions