keystone.common.cache package

Submodules

keystone.common.cache.core module

Keystone Caching Layer Implementation.

class keystone.common.cache.core.DebugProxy(*args, **kwargs)[source]

Bases: dogpile.cache.proxy.ProxyBackend

Extra Logging ProxyBackend.

delete(key)[source]
delete_multi(keys)[source]
get(key)[source]
get_multi(keys)[source]
set(key, value)[source]
set_multi(keys)[source]
keystone.common.cache.core.build_cache_config()[source]

Build the cache region dictionary configuration.

Returns:dict
keystone.common.cache.core.configure_cache_region(region)[source]

Configure a cache region.

Parameters:region – optional CacheRegion object, if not provided a new region will be instantiated
Raises:exception.ValidationError
Returns:dogpile.cache.CacheRegion
keystone.common.cache.core.function_key_generator(namespace, fn, to_str=<function key_generate_to_str at 0x55077d0>)[source]
keystone.common.cache.core.get_expiration_time_fn(section)[source]

Build a function that returns a config section’s expiration time status.

For any given driver in keystone that has caching capabilities, an int config option called cache_time for that driver’s section (e.g. token) should exist and typically default to None. This function will use that value to tell the caching decorator of the TTL override for caching the resulting objects. If the value of the config option is None the default value provided in the [cache] expiration_time option will be used by the decorator. The default may be set to something other than None in cases where the caching TTL should not be tied to the global default(s) (e.g. revocation_list changes very infrequently and can be cached for >1h by default).

To properly use this with the decorator, pass this function the configuration section and assign the result to a variable. Pass the new variable to the caching decorator as the named argument expiration_time. e.g.:

from keystone.common import cache

EXPIRATION_TIME = cache.get_expiration_time_fn('token')

@cache.on_arguments(expiration_time=EXPIRATION_TIME)
def function(arg1, arg2):
    ...
Parameters:section (string) – name of the configuration section to examine
Return type:function reference
keystone.common.cache.core.get_memoization_decorator(section, expiration_section=None)[source]

Build a function based on the on_arguments decorator for the section.

For any given driver in Keystone that has caching capabilities, a pair of functions is required to properly determine the status of the caching capabilities (a toggle to indicate caching is enabled and any override of the default TTL for cached data). This function will return an object that has the memoization decorator on_arguments pre-configured for the driver.

Example usage:

from keystone.common import cache

MEMOIZE = cache.get_memoization_decorator(section='token')

@MEMOIZE
def function(arg1, arg2):
    ...


ALTERNATE_MEMOIZE = cache.get_memoization_decorator(
    section='token', expiration_section='revoke')

@ALTERNATE_MEMOIZE
def function2(arg1, arg2):
    ...
Parameters:
  • section (string) – name of the configuration section to examine
  • expiration_section (string) – name of the configuration section to examine for the expiration option. This will fall back to using section if the value is unspecified or None
Return type:

function reference

keystone.common.cache.core.get_should_cache_fn(section)[source]

Build a function that returns a config section’s caching status.

For any given driver in keystone that has caching capabilities, a boolean config option for that driver’s section (e.g. token) should exist and default to True. This function will use that value to tell the caching decorator if caching for that driver is enabled. To properly use this with the decorator, pass this function the configuration section and assign the result to a variable. Pass the new variable to the caching decorator as the named argument should_cache_fn. e.g.:

from keystone.common import cache

SHOULD_CACHE = cache.get_should_cache_fn('token')

@cache.on_arguments(should_cache_fn=SHOULD_CACHE)
def function(arg1, arg2):
    ...
Parameters:section (string) – name of the configuration section to examine
Returns:function reference
keystone.common.cache.core.key_generate_to_str(s)[source]

Module contents

Table Of Contents

This Page