本文整理汇总了Python中django.core.cache.backends.base.BaseCache方法的典型用法代码示例。如果您正苦于以下问题:Python base.BaseCache方法的具体用法?Python base.BaseCache怎么用?Python base.BaseCache使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.core.cache.backends.base
的用法示例。
在下文中一共展示了base.BaseCache方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_cache_key_memcache_validation
# 需要导入模块: from django.core.cache.backends import base [as 别名]
# 或者: from django.core.cache.backends.base import BaseCache [as 别名]
def test_cache_key_memcache_validation(self):
"""
Handle cache key creation correctly, see #17861.
"""
name = (
"/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff"
"/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff"
"/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff"
"/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff"
"/some crazy/long filename/ with spaces Here and ?#%#$/other/stuff"
"/some crazy/\x16\xb4"
)
cache_key = storage.staticfiles_storage.hash_key(name)
cache_validator = BaseCache({})
cache_validator.validate_key(cache_key)
self.assertEqual(cache_key, 'staticfiles:821ea71ef36f95b3922a77f7364670e7')
示例2: get_cache_backend
# 需要导入模块: from django.core.cache.backends import base [as 别名]
# 或者: from django.core.cache.backends.base import BaseCache [as 别名]
def get_cache_backend(cache_name: Optional[str]) -> BaseCache:
if cache_name is None:
return djcache
return caches[cache_name]