本文整理汇总了Python中environ.Env.cache_url_config方法的典型用法代码示例。如果您正苦于以下问题:Python Env.cache_url_config方法的具体用法?Python Env.cache_url_config怎么用?Python Env.cache_url_config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类environ.Env
的用法示例。
在下文中一共展示了Env.cache_url_config方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_base_options_parsing
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import cache_url_config [as 别名]
def test_base_options_parsing(self):
url = 'memcache://127.0.0.1:11211/?timeout=0&key_prefix=cache_&key_function=foo.get_key&version=1'
url = Env.cache_url_config(url)
self.assertEqual(url['KEY_PREFIX'], 'cache_')
self.assertEqual(url['KEY_FUNCTION'], 'foo.get_key')
self.assertEqual(url['TIMEOUT'], 0)
self.assertEqual(url['VERSION'], 1)
url = 'redis://127.0.0.1:6379/?timeout=None'
url = Env.cache_url_config(url)
self.assertEqual(url['TIMEOUT'], None)
示例2: test_redis_parsing
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import cache_url_config [as 别名]
def test_redis_parsing(self):
url = 'rediscache://127.0.0.1:6379:1?client_class=django_redis.client.DefaultClient&password=secret'
url = Env.cache_url_config(url)
self.assertEqual(url['BACKEND'], 'django_redis.cache.RedisCache')
self.assertEqual(url['LOCATION'], '127.0.0.1:6379:1')
self.assertEqual(url['OPTIONS'], {
'CLIENT_CLASS': 'django_redis.client.DefaultClient',
'PASSWORD': 'secret',
})
示例3: test_redis_multi_location_parsing
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import cache_url_config [as 别名]
def test_redis_multi_location_parsing(self):
url = 'rediscache://host1:6379,host2:6379,host3:9999/1'
url = Env.cache_url_config(url)
self.assertEqual(url['BACKEND'], REDIS_DRIVER)
self.assertEqual(url['LOCATION'], [
'redis://host1:6379/1',
'redis://host2:6379/1',
'redis://host3:9999/1',
])
示例4: test_custom_backend
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import cache_url_config [as 别名]
def test_custom_backend(self):
url = 'memcache://127.0.0.1:5400?foo=option&bars=9001'
backend = 'django_redis.cache.RedisCache'
url = Env.cache_url_config(url, backend)
self.assertEqual(url['BACKEND'], backend)
self.assertEqual(url['LOCATION'], '127.0.0.1:5400')
self.assertEqual(url['OPTIONS'], {
'FOO': 'option',
'BARS': 9001,
})
示例5: test_options_parsing
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import cache_url_config [as 别名]
def test_options_parsing(self):
url = 'filecache:///var/tmp/django_cache?timeout=60&max_entries=1000&cull_frequency=0'
url = Env.cache_url_config(url)
self.assertEqual(url['BACKEND'], 'django.core.cache.backends.filebased.FileBasedCache')
self.assertEqual(url['LOCATION'], '/var/tmp/django_cache')
self.assertEqual(url['TIMEOUT'], 60)
self.assertEqual(url['OPTIONS'], {
'MAX_ENTRIES': 1000,
'CULL_FREQUENCY': 0,
})
示例6: test_redis_socket_parsing
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import cache_url_config [as 别名]
def test_redis_socket_parsing(self):
url = 'rediscache:///path/to/socket:1'
url = Env.cache_url_config(url)
self.assertEqual(url['BACKEND'], 'django_redis.cache.RedisCache')
self.assertEqual(url['LOCATION'], 'unix:/path/to/socket:1')
示例7: test_dummycache_parsing
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import cache_url_config [as 别名]
def test_dummycache_parsing(self):
url = 'dummycache://'
url = Env.cache_url_config(url)
self.assertEqual(url['BACKEND'], 'django.core.cache.backends.dummy.DummyCache')
self.assertEqual(url['LOCATION'], '')
示例8: test_locmem_named_parsing
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import cache_url_config [as 别名]
def test_locmem_named_parsing(self):
url = 'locmemcache://unique-snowflake'
url = Env.cache_url_config(url)
self.assertEqual(url['BACKEND'], 'django.core.cache.backends.locmem.LocMemCache')
self.assertEqual(url['LOCATION'], 'unique-snowflake')
示例9: test_filecache_windows_parsing
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import cache_url_config [as 别名]
def test_filecache_windows_parsing(self):
url = 'filecache://C:/foo/bar'
url = Env.cache_url_config(url)
self.assertEqual(url['BACKEND'], 'django.core.cache.backends.filebased.FileBasedCache')
self.assertEqual(url['LOCATION'], 'C:/foo/bar')
示例10: test_filecache_parsing
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import cache_url_config [as 别名]
def test_filecache_parsing(self):
url = 'filecache:///var/tmp/django_cache'
url = Env.cache_url_config(url)
self.assertEqual(url['BACKEND'], 'django.core.cache.backends.filebased.FileBasedCache')
self.assertEqual(url['LOCATION'], '/var/tmp/django_cache')
示例11: test_dbcache_parsing
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import cache_url_config [as 别名]
def test_dbcache_parsing(self):
url = 'dbcache://my_cache_table'
url = Env.cache_url_config(url)
self.assertEqual(url['BACKEND'], 'django.core.cache.backends.db.DatabaseCache')
self.assertEqual(url['LOCATION'], 'my_cache_table')
示例12: test_memcache_socket_parsing
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import cache_url_config [as 别名]
def test_memcache_socket_parsing(self):
url = 'memcache:///tmp/memcached.sock'
url = Env.cache_url_config(url)
self.assertEqual(url['BACKEND'], 'django.core.cache.backends.memcached.MemcachedCache')
self.assertEqual(url['LOCATION'], 'unix:/tmp/memcached.sock')
示例13: test_memcache_multiple_parsing
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import cache_url_config [as 别名]
def test_memcache_multiple_parsing(self):
url = 'memcache://172.19.26.240:11211,172.19.26.242:11212'
url = Env.cache_url_config(url)
self.assertEqual(url['BACKEND'], 'django.core.cache.backends.memcached.MemcachedCache')
self.assertEqual(url['LOCATION'], ['172.19.26.240:11211', '172.19.26.242:11212'])
示例14: test_memcache_pylib_parsing
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import cache_url_config [as 别名]
def test_memcache_pylib_parsing(self):
url = 'pymemcache://127.0.0.1:11211'
url = Env.cache_url_config(url)
self.assertEqual(url['BACKEND'], 'django.core.cache.backends.memcached.PyLibMCCache')
self.assertEqual(url['LOCATION'], '127.0.0.1:11211')