当前位置: 首页>>代码示例>>Python>>正文


Python Env.cache_url_config方法代码示例

本文整理汇总了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)
开发者ID:bmd-monika,项目名称:TestMonika,代码行数:15,代码来源:test.py

示例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',
        })
开发者ID:AliLozano,项目名称:django-environ,代码行数:12,代码来源:test.py

示例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',
        ])
开发者ID:bmd-monika,项目名称:TestMonika,代码行数:12,代码来源:test.py

示例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,
        })
开发者ID:AliLozano,项目名称:django-environ,代码行数:13,代码来源:test.py

示例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,
        })
开发者ID:AliLozano,项目名称:django-environ,代码行数:13,代码来源:test.py

示例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')
开发者ID:AliLozano,项目名称:django-environ,代码行数:7,代码来源:test.py

示例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'], '')
开发者ID:AliLozano,项目名称:django-environ,代码行数:8,代码来源:test.py

示例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')
开发者ID:AliLozano,项目名称:django-environ,代码行数:8,代码来源:test.py

示例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')
开发者ID:AliLozano,项目名称:django-environ,代码行数:8,代码来源:test.py

示例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')
开发者ID:AliLozano,项目名称:django-environ,代码行数:8,代码来源:test.py

示例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')
开发者ID:AliLozano,项目名称:django-environ,代码行数:8,代码来源:test.py

示例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')
开发者ID:AliLozano,项目名称:django-environ,代码行数:8,代码来源:test.py

示例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'])
开发者ID:AliLozano,项目名称:django-environ,代码行数:8,代码来源:test.py

示例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')
开发者ID:AliLozano,项目名称:django-environ,代码行数:8,代码来源:test.py


注:本文中的environ.Env.cache_url_config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。