本文整理汇总了Python中memcacheify.memcacheify函数的典型用法代码示例。如果您正苦于以下问题:Python memcacheify函数的具体用法?Python memcacheify怎么用?Python memcacheify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了memcacheify函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_uses_local_memory_backend_if_no_memcachier_addon_is_available
def test_uses_local_memory_backend_if_no_memcachier_addon_is_available(self):
environ['MEMCACHIER_PASSWORD'] = 'xxx'
environ['MEMCACHIER_SERVERS'] = 'mc1.ec2.memcachier.com'
self.assertEqual(memcacheify(), {'default':
{'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}
})
del environ['MEMCACHIER_PASSWORD']
del environ['MEMCACHIER_SERVERS']
示例2: test_sets_proper_backend_when_memcache_addon_is_available
def test_sets_proper_backend_when_memcache_addon_is_available(self):
environ["MEMCACHE_PASSWORD"] = "GCnQ9DhfEJqNDlo1"
environ["MEMCACHE_SERVERS"] = "mc3.ec2.northscale.net"
environ["MEMCACHE_USERNAME"] = "appxxxxx%40heroku.com"
self.assertEqual(memcacheify()["default"]["BACKEND"], "django_pylibmc.memcached.PyLibMCCache")
del environ["MEMCACHE_PASSWORD"]
del environ["MEMCACHE_SERVERS"]
del environ["MEMCACHE_USERNAME"]
示例3: tests_uses_local_memory_backend_if_one_of_the_memcache_env_vars_is_missing
def tests_uses_local_memory_backend_if_one_of_the_memcache_env_vars_is_missing(self):
environ['MEMCACHE_PASSWORD'] = 'GCnQ9DhfEJqNDlo1'
environ['MEMCACHE_SERVERS'] = 'mc3.ec2.northscale.net'
self.assertEqual(memcacheify(), {'default':
{'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}
})
del environ['MEMCACHE_PASSWORD']
del environ['MEMCACHE_SERVERS']
示例4: test_sets_proper_backend_when_memcache_addon_is_available
def test_sets_proper_backend_when_memcache_addon_is_available(self):
environ['MEMCACHE_PASSWORD'] = 'GCnQ9DhfEJqNDlo1'
environ['MEMCACHE_SERVERS'] = 'mc3.ec2.northscale.net'
environ['MEMCACHE_USERNAME'] = 'appxxxxx%40heroku.com'
self.assertEqual(memcacheify()['default']['BACKEND'],
'django_pylibmc.memcached.PyLibMCCache')
del environ['MEMCACHE_PASSWORD']
del environ['MEMCACHE_SERVERS']
del environ['MEMCACHE_USERNAME']
示例5: get_cache_config
def get_cache_config():
"""Return a fully configured Django ``CACHES`` setting.
Scans environment variables for available memcache addon.
Additionally includes Django's LocMemCache backend under ``"locmem"``
cache name.
"""
caches = memcacheify()
caches["locmem"] = {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache"
}
return caches
示例6: test_sets_proper_backend_when_memcachier_addon_is_available
def test_sets_proper_backend_when_memcachier_addon_is_available(self):
environ["MEMCACHIER_PASSWORD"] = "xxx"
environ["MEMCACHIER_SERVERS"] = "mc1.ec2.memcachier.com"
environ["MEMCACHIER_USERNAME"] = "xxx"
caches = memcacheify()
self.assertEqual(caches["default"]["BACKEND"], "django_pylibmc.memcached.PyLibMCCache")
self.assertEqual(environ["MEMCACHE_SERVERS"], environ["MEMCACHIER_SERVERS"])
self.assertEqual(environ["MEMCACHE_USERNAME"], environ["MEMCACHIER_USERNAME"])
self.assertEqual(environ["MEMCACHE_PASSWORD"], environ["MEMCACHIER_PASSWORD"])
del environ["MEMCACHIER_PASSWORD"]
del environ["MEMCACHIER_SERVERS"]
del environ["MEMCACHIER_USERNAME"]
del environ["MEMCACHE_PASSWORD"]
del environ["MEMCACHE_SERVERS"]
del environ["MEMCACHE_USERNAME"]
示例7: test_sets_proper_backend_when_memcachedcloud_addon_is_available
def test_sets_proper_backend_when_memcachedcloud_addon_is_available(self):
environ['MEMCACHEDCLOUD_PASSWORD'] = 'xyz'
environ['MEMCACHEDCLOUD_SERVERS'] = 'zzzz'
environ['MEMCACHEDCLOUD_USERNAME'] = 'xyzzy'
caches = memcacheify()
self.assertEqual(caches['default']['BACKEND'], 'django_pylibmc.memcached.PyLibMCCache')
self.assertEqual(environ['MEMCACHE_SERVERS'], environ['MEMCACHEDCLOUD_SERVERS'])
self.assertEqual(environ['MEMCACHE_USERNAME'], environ['MEMCACHEDCLOUD_USERNAME'])
self.assertEqual(environ['MEMCACHE_PASSWORD'], environ['MEMCACHEDCLOUD_PASSWORD'])
del environ['MEMCACHEDCLOUD_PASSWORD']
del environ['MEMCACHEDCLOUD_SERVERS']
del environ['MEMCACHEDCLOUD_USERNAME']
del environ['MEMCACHE_PASSWORD']
del environ['MEMCACHE_SERVERS']
del environ['MEMCACHE_USERNAME']
示例8: CACHES
def CACHES(self):
"""
Return a fully configured Django ``CACHES`` setting.
Scans environment variables for available memcache add-on.
Additionally includes Django's LocMemCache backend under ``"locmem"``
cache name.
"""
from memcacheify import memcacheify
caches = memcacheify()
caches.update({
"locmem": {
"BACKEND": "django.core.cache.backends.locmem.LocMemCache"
},
"dummy": {
"BACKEND": "django.core.cache.backends.dummy.DummyCache",
}
})
return caches
示例9: postgresify
EMAIL_USE_TLS = True
# See: https://docs.djangoproject.com/en/dev/ref/settings/#server-email
SERVER_EMAIL = EMAIL_HOST_USER
## Database configuration
# See: https://docs.djangoproject.com/en/dev/ref/settings/#databases
DATABASES = postgresify()
## Cache configuration
# See: https://docs.djangoproject.com/en/dev/ref/settings/#caches
if CACHES is None:
CACHES = dict()
CACHES.update(memcacheify())
## Secret key configuration
# See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key
# Use the value set in the Heroku configuration.
SECRET_KEY = os.environ.get('SECRET_KEY', SECRET_KEY)
## Gunicorn configuration
# See: http://gunicorn.org/run.html
# See: https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/gunicorn/
INSTALLED_APPS += (
'gunicorn',
)
示例10: memcacheify
DATABASES = {
'default': env.db(),
}
#####
# Cache Settings
# Attempt to get the memcache info from Heroku.
try:
# `django-heroku-memcachify` requires memcache to work. Since we only
# need it on heroku and don't want to require libmemcached on dev
# machines, we'll only use it if it's installed
from memcacheify import memcacheify
default_cache = memcacheify()['default']
# memcacheify will use the LocMemCache if there is no heroku cache. So if
# we see the 'LocMemCache' we know that memcachify is not running on a
# heroku dyno that is setup for memcached
# pylint: disable=line-too-long
if default_cache['BACKEND'] == 'django.core.cache.backends.locmem.LocMemCache':
default_cache = env.cache()
except ImportError:
# If `django-heroku-memcachify` is not installed, just use the cache
# defined in the environment
default_cache = env.cache()
CACHES = {
示例11: test_uses_local_memory_backend_if_no_memcachier_addon_is_available
def test_uses_local_memory_backend_if_no_memcachier_addon_is_available(self):
environ["MEMCACHIER_PASSWORD"] = "xxx"
environ["MEMCACHIER_SERVERS"] = "mc1.ec2.memcachier.com"
self.assertEqual(memcacheify(), {"default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}})
del environ["MEMCACHIER_PASSWORD"]
del environ["MEMCACHIER_SERVERS"]
示例12: test_uses_local_memory_backend_if_no_memcache_addon_is_available
def test_uses_local_memory_backend_if_no_memcache_addon_is_available(self):
self.assertEqual(memcacheify(), {"default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}})
示例13: test_uses_local_memory_backend_if_no_memcache_addon_is_available
def test_uses_local_memory_backend_if_no_memcache_addon_is_available(self):
self.assertEqual(memcacheify(), {'default':
{'BACKEND': 'django.core.cache.backends.locmem.LocMemCache'}
})
示例14: memcacheify
KEY_PREFIX = TREEHERDER_MEMCACHED_KEY_PREFIX
# celery broker setup
BROKER_URL = 'amqp://{0}:{1}@{2}:{3}/{4}'.format(
RABBITMQ_USER,
RABBITMQ_PASSWORD,
RABBITMQ_HOST,
RABBITMQ_PORT,
RABBITMQ_VHOST
)
# This code handles the memcachier service on heroku.
if "IS_HEROKU" in os.environ:
from memcacheify import memcacheify
CACHES['default'].update(
memcacheify().get('default')
)
if "CLOUDAMQP_URL" in os.environ:
BROKER_URL = os.environ["CLOUDAMQP_URL"]
BROKER_POOL_LIMIT = 1
CELERY_IGNORE_RESULT = True
API_HOSTNAME = SITE_URL
BROWSERID_AUDIENCES = [SITE_URL]
SWAGGER_SETTINGS = {"enabled_methods": ['get', ]}
REST_FRAMEWORK_EXTENSIONS = {
示例15: tests_uses_local_memory_backend_if_one_of_the_memcache_env_vars_is_missing
def tests_uses_local_memory_backend_if_one_of_the_memcache_env_vars_is_missing(self):
environ["MEMCACHE_PASSWORD"] = "GCnQ9DhfEJqNDlo1"
environ["MEMCACHE_SERVERS"] = "mc3.ec2.northscale.net"
self.assertEqual(memcacheify(), {"default": {"BACKEND": "django.core.cache.backends.locmem.LocMemCache"}})
del environ["MEMCACHE_PASSWORD"]
del environ["MEMCACHE_SERVERS"]