diff --git a/oslo_cache/core.py b/oslo_cache/core.py index eb023ff4..060e444b 100644 --- a/oslo_cache/core.py +++ b/oslo_cache/core.py @@ -14,18 +14,10 @@ """Caching Layer Implementation. -When this library is imported, it registers the following backends in -:mod:`dogpile.cache`: - -* ``oslo_cache.noop`` - :class:`oslo_cache.backends.noop.NoopCacheBackend` -* ``oslo_cache.mongo`` - :class:`oslo_cache.backends.mongo.MongoCacheBackend` -* ``oslo_cache.memcache_pool`` - - :class:`oslo_cache.backends.memcache_pool.PooledMemcachedBackend` -* ``oslo_cache.dict`` - - :class:`oslo_cache.backends.dictionary.DictCacheBackend` - 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 @@ -66,9 +58,6 @@ _BACKENDS = [ ('oslo_cache.dict', 'oslo_cache.backends.dictionary', 'DictCacheBackend'), ] -for backend in _BACKENDS: - dogpile.cache.register_backend(*backend) - class _DebugProxy(proxy.ProxyBackend): """Extra Logging ProxyBackend.""" @@ -367,8 +356,21 @@ def configure(conf): This must be called before conf(). + The following backends are registered in :mod:`dogpile.cache`: + + * ``oslo_cache.noop`` - :class:`oslo_cache.backends.noop.NoopCacheBackend` + * ``oslo_cache.mongo`` - + :class:`oslo_cache.backends.mongo.MongoCacheBackend` + * ``oslo_cache.memcache_pool`` - + :class:`oslo_cache.backends.memcache_pool.PooledMemcachedBackend` + * ``oslo_cache.dict`` - + :class:`oslo_cache.backends.dictionary.DictCacheBackend` + :param conf: The configuration object. :type conf: oslo_config.cfg.ConfigOpts """ _opts.configure(conf) + + for backend in _BACKENDS: + dogpile.cache.register_backend(*backend) diff --git a/oslo_cache/tests/__init__.py b/oslo_cache/tests/__init__.py index e31d5cda..f34b0577 100644 --- a/oslo_cache/tests/__init__.py +++ b/oslo_cache/tests/__init__.py @@ -10,9 +10,9 @@ # License for the specific language governing permissions and limitations # under the License. -from oslo_cache import _opts +from oslo_cache import core from oslo_config import cfg -_opts.configure(cfg.CONF) +core.configure(cfg.CONF)