Python django.conf.settings.REDIS_DB Examples
The following are 2
code examples of django.conf.settings.REDIS_DB().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
django.conf.settings
, or try the search function
.
Example #1
Source File: cache.py From koku with GNU Affero General Public License v3.0 | 5 votes |
def invalidate_view_cache_for_tenant_and_cache_key(schema_name, cache_key_prefix=None): """Invalidate our view cache for a specific tenant and source type. If cache_key_prefix is None, all views will be invalidated. """ cache = caches["default"] if isinstance(cache, RedisCache): cache = Redis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB) all_keys = cache.keys("*") all_keys = [key.decode("utf-8") for key in all_keys] elif isinstance(cache, LocMemCache): all_keys = list(locmem._caches.get(settings.TEST_CACHE_LOCATION).keys()) all_keys = [key.split(":", 2)[-1] for key in all_keys] else: msg = "Using an unsupported caching backend!" raise KokuCacheError(msg) all_keys = all_keys if all_keys is not None else [] if cache_key_prefix: keys_to_invalidate = [key for key in all_keys if (schema_name in key and cache_key_prefix in key)] else: # Invalidate all cached views for the tenant keys_to_invalidate = [key for key in all_keys if schema_name in key] for key in keys_to_invalidate: cache.delete(key) msg = f"Invalidated request cache for\n\ttenant: {schema_name}\n\tcache_key_prefix: {cache_key_prefix}" LOG.info(msg)
Example #2
Source File: pwdmanager.py From freeipa-password-reset with GNU General Public License v3.0 | 5 votes |
def __init__(self): if self.__kerberos_has_ticket() is False: self.__kerberos_init() if api.isdone('finalize') is False: api.bootstrap_with_global_options(context='api') api.finalize() api.Backend.rpcclient.connect() self.redis = redis.StrictRedis(host=settings.REDIS_HOST, port=settings.REDIS_PORT, db=settings.REDIS_DB, password=settings.REDIS_PASSWORD)