Why Gemfury? Push, build, and install  RubyGems npm packages Python packages Maven artifacts PHP packages Go Modules Debian packages RPM packages NuGet packages

Repository URL to install this package:

Details    
Size: Mime:
ó
»EYc@s<dZddlZddlmZddlmZddlmZddlmZddlm	Z	ddl
mZdd	lm
Z
dd
lmZddd
ddgZejZejeƒZdejfd„ƒYZd„Zd„Zd„Zd„Zd„Zd„Zd„Zed„Zdd„Zd„Z dS(sXCaching Layer Implementation.

To use this library:

You must call :func:`configure`.

Inside your application code, decorate the methods that you want the results
to be cached with a memoization decorator created with
:func:`get_memoization_decorator`. This function takes a group name from the
config. Register [`group`] ``caching`` and [`group`] ``cache_time`` options
for the groups that your decorators use so that caching can be configured.

This library's configuration options must be registered in your application's
:class:`oslo_config.cfg.ConfigOpts` instance. Do this by passing the ConfigOpts
instance to :func:`configure`.

The library has special public value for nonexistent or expired keys called
:data:`NO_VALUE`. To use this value you should import it from oslo_cache.core::

    from oslo_cache import core
    NO_VALUE = core.NO_VALUE
iÿÿÿÿN(tapi(tproxy(tutil(tlog(timportutils(t_(t_opts(t	exceptiont	configuretconfigure_cache_regiont
create_regiontget_memoization_decoratortNO_VALUEt_DebugProxycBsDeZdZd„Zd„Zd„Zd„Zd„Zd„ZRS(sExtra Logging ProxyBackend.cCs4|jj|ƒ}tjdi|d6|d6ƒ|S(Ns,CACHE_GET: Key: "%(key)r" Value: "%(value)r"tkeytvalue(tproxiedtgett_LOGtdebug(tselfRR((sD/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_cache/core.pyRHs	cCs4|jj|ƒ}tjdi|d6|d6ƒ|S(Ns0CACHE_GET_MULTI: "%(keys)r" Values: "%(values)r"tkeystvalues(Rt	get_multiRR(RRR((sD/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_cache/core.pyRNs	cCs1tjdi|d6|d6ƒ|jj||ƒS(Ns,CACHE_SET: Key: "%(key)r" Value: "%(value)r"RR(RRRtset(RRR((sD/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_cache/core.pyRTs	cCs$tjd|ƒ|jj|ƒdS(NsCACHE_SET_MULTI: "%r"(RRRt	set_multi(RR((sD/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_cache/core.pyRYscCs$|jj|ƒtjd|ƒdS(NsCACHE_DELETE: "%r"(RtdeleteRR(RR((sD/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_cache/core.pyR]scCs$tjd|ƒ|jj|ƒdS(NsCACHE_DELETE_MULTI: "%r"(RRRtdelete_multi(RR((sD/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_cache/core.pyRas(	t__name__t
__module__t__doc__RRRRRR(((sD/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_cache/core.pyR
@s					c
CsK|jj}i}tj|d|<|jjtkrL|jj|d|<n|jj|d|<x|jjD]}y|j	ddƒ\}}Wn*t
k
r»d}tj||ƒqmnXdj
|d|gƒ}|||<tjd|ƒqmW|jd	||jjƒx8dD]0}t|jd|ƒ}	|	|d||f<qW|S(sIBuild the cache region dictionary configuration.

    :returns: dict
    s
%s.backends%s.expiration_timet:isbUnable to build cache config-key. Expected format "<argname>:<value>". Skipping unknown format: %st.t	argumentssOslo Cache Config: %ss%s.arguments.urlt
dead_retrytsocket_timeouttpool_maxsizetpool_unused_timeouttpool_connection_get_timeoutt	memcache_s%s.arguments.%s(R"ssocket_timeoutR$R%R&(tcachet
config_prefixRt_DEFAULT_BACKENDtenabledtTruetbackendtexpiration_timetbackend_argumenttsplitt
ValueErrorRterrortjoinRt
setdefaulttmemcache_serverstgetattr(
tconftprefixt	conf_dicttargumenttargnametargvaluetmsgtarg_keytargR((sD/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_cache/core.pyt_build_cache_configfs.




cCs@y|jdddƒ}Wnttfk
r2nXtj|ƒS(sÑWrapper for dogpile's sha1_mangle_key.

    dogpile's sha1_mangle_key function expects an encoded string, so we
    should take steps to properly handle multiple inputs before passing
    the key through.
    sutf-8terrorstxmlcharrefreplace(tencodetUnicodeErrortAttributeErrorRtsha1_mangle_key(R((sD/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_cache/core.pyt_sha1_mangle_key‹s
cCstjjdtƒS(sVCreate a region.

    This is just dogpile.cache.make_region, but the key generator has a
    different to_str mechanism.

    .. note::

        You must call :func:`configure_cache_region` with this region before
        a memoized method is called.

    :returns: The new region.
    :rtype: :class:`dogpile.cache.region.CacheRegion`

    tfunction_key_generator(tdogpileR(tmake_regiont_function_key_generator(((sD/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_cache/core.pyR
šscCsÝt|tjjƒs-tjtdƒƒ‚n|jsÙt|ƒ}|j	|d|jj
ƒ|jjrx|jt
ƒn|jdkr“t|_nxC|jjD]2}tj|ƒ}tjd|ƒ|j|ƒq Wn|S(sSConfigure a cache region.

    If the cache region is already configured, this function does nothing.
    Otherwise, the region is configured.

    :param conf: config object, must have had :func:`configure` called on it.
    :type conf: oslo_config.cfg.ConfigOpts
    :param region: Cache region to configure (see :func:`create_region`).
    :type region: dogpile.cache.region.CacheRegion
    :raises oslo_cache.exception.ConfigurationError: If the region parameter is
        not a dogpile.cache.CacheRegion.
    :returns: The region.
    :rtype: :class:`dogpile.cache.region.CacheRegion`
    s)region not type dogpile.cache.CacheRegions%s.s#Adding cache-proxy '%s' to backend.N(t
isinstanceRIR(tCacheRegionRtConfigurationErrorRt
is_configuredR@tconfigure_from_configR)tdebug_cache_backendtwrapR
tkey_manglertNoneRGtproxiesRtimport_classRR(R7tregiontconfig_dictt
class_pathtcls((sD/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_cache/core.pyR	®s 		cs‡‡fd†}|S(sBuild a function that returns a config group's caching status.

    For any given object that has caching capabilities, a boolean config option
    for that object's group should exist and default to ``True``. This
    function will use that value to tell the caching decorator if caching for
    that object is enabled. To properly use this with the decorator, pass this
    function the configuration group and assign the result to a variable.
    Pass the new variable to the caching decorator as the named argument
    ``should_cache_fn``.

    :param conf: config object, must have had :func:`configure` called on it.
    :type conf: oslo_config.cfg.ConfigOpts
    :param group: name of the configuration group to examine
    :type group: string
    :returns: function reference
    cs/ˆjjstStˆˆƒ}t|dtƒS(Ntcaching(R(R+tFalseR6R,(Rt
conf_group(R7tgroup(sD/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_cache/core.pytshould_cacheôs((R7R^R_((R7R^sD/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_cache/core.pyt_get_should_cache_fnãscs‡‡fd†}|S(sùBuild a function that returns a config group's expiration time status.

    For any given object that has caching capabilities, an int config option
    called ``cache_time`` for that driver's group 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).

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

    :param group: name of the configuration group to examine
    :type group: string
    :rtype: function reference
    cstˆˆƒ}t|ddƒS(Nt
cache_time(R6RT(R](R7R^(sD/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_cache/core.pytget_expiration_times((R7R^Rb((R7R^sD/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_cache/core.pyt_get_expiration_time_fnüscCs0yt|ƒSWntk
r+|jdƒSXdS(Nsutf-8(tstrtUnicodeEncodeErrorRC(ts((sD/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_cache/core.pyt_key_generate_to_strs
cCstj||d|ƒS(Ntto_str(RRH(t	namespacetfnRh((sD/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_cache/core.pyRK scCsa|dkr|}nt||ƒ}t||ƒ}|jd|d|ƒ}||_||_|S(sþBuild a function based on the `cache_on_arguments` decorator.

    The memoization decorator that gets created by this function is a
    :meth:`dogpile.cache.region.CacheRegion.cache_on_arguments` decorator,
    where

    * The ``should_cache_fn`` is set to a function that returns True if both
      the ``[cache] enabled`` option is true and [`group`] ``caching`` is
      True.

    * The ``expiration_time`` is set from the
      [`expiration_group`] ``cache_time`` option if ``expiration_group``
      is passed in and the value is set, or [`group`] ``cache_time`` if
      ``expiration_group`` is not passed in and the value is set, or
      ``[cache] expiration_time`` otherwise.

    Example usage::

        import oslo_cache.core

        MEMOIZE = oslo_cache.core.get_memoization_decorator(
            conf, region, group='group1')

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


        ALTERNATE_MEMOIZE = oslo_cache.core.get_memoization_decorator(
            conf, region, group='group2', expiration_group='group3')

        @ALTERNATE_MEMOIZE
        def function2(arg1, arg2):
            ...

    :param conf: config object, must have had :func:`configure` called on it.
    :type conf: oslo_config.cfg.ConfigOpts
    :param region: region as created by :func:`create_region`.
    :type region: dogpile.cache.region.CacheRegion
    :param group: name of the configuration group to examine
    :type group: string
    :param expiration_group: name of the configuration group to examine
                             for the expiration option. This will fall back to
                             using ``group`` if the value is unspecified or
                             ``None``
    :type expiration_group: string
    :rtype: function reference
    tshould_cache_fnR.N(RTR`Rctcache_on_argumentsR_Rb(R7RWR^texpiration_groupR_R.tmemoize((sD/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_cache/core.pyR&s1				cCstj|ƒdS(sConfigure the library.

    Register the required oslo.cache config options into an oslo.config CONF
    object.

    This must be called before :py:func:`configure_cache_region`.

    :param conf: The configuration object.
    :type conf: oslo_config.cfg.ConfigOpts
    N(RR(R7((sD/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_cache/core.pyRhs(!Rt
dogpile.cacheRIRRRtoslo_logRt
oslo_utilsRtoslo_cache._i18nRt
oslo_cacheRRt__all__Rt	getLoggerRRtProxyBackendR
R@RGR
R	R`RcRgRKRTRR(((sD/home/tvault/.virtenv/lib/python2.7/site-packages/oslo_cache/core.pyt<module>$s6		&	%			5				B