Changeset - 38749d420fbd
[Not reviewed]
default
0 1 0
Mads Kiilerich - 6 years ago 2019-12-16 01:51:47
mads@kiilerich.com
Grafted from: 3217d745472e
cache: keep caching_query cacke_key in unicode ... and always include limit and offset to avoid any ambiguity
1 file changed with 5 insertions and 5 deletions:
0 comments (0 inline, 0 general)
kallithea/lib/caching_query.py
Show inline comments
 
@@ -21,13 +21,13 @@ Beaker constructs.
 
import beaker
 
from beaker.exceptions import BeakerException
 
from sqlalchemy.orm.interfaces import MapperOption
 
from sqlalchemy.orm.query import Query
 
from sqlalchemy.sql import visitors
 

	
 
from kallithea.lib.utils2 import safe_str
 
from kallithea.lib.utils2 import safe_str, safe_unicode
 

	
 

	
 
class CachingQuery(Query):
 
    """A Query subclass which optionally loads full results from a Beaker
 
    cache region.
 

	
 
@@ -135,16 +135,16 @@ def _get_cache_parameters(query):
 
    region, namespace, cache_key = query._cache_parameters
 

	
 
    namespace = _namespace_from_query(namespace, query)
 

	
 
    if cache_key is None:
 
        # cache key - the value arguments from this query's parameters.
 
        args = [safe_str(x) for x in _params_from_query(query)]
 
        args.extend([k for k in [str(query._limit), str(query._offset)] if k not in ['None', None, u'None']])
 

	
 
        cache_key = " ".join(args)
 
        args = _params_from_query(query)
 
        args.append(query._limit)
 
        args.append(query._offset)
 
        cache_key = " ".join(safe_unicode(x) for x in args)
 

	
 
    if cache_key is None:
 
        raise Exception('Cache key cannot be None')
 

	
 
    # get cache
 
    #cache = query.cache_manager.get_cache_region(namespace, region)
0 comments (0 inline, 0 general)