Don't register backends on import

Doing things on import is questionable. Move the activity into
the configure function since that has to be called anyways.

Change-Id: Ia70207710f6b966b20389a43d94a34599e58e5ab
This commit is contained in:
Brant Knudson 2015-07-08 19:38:10 -05:00
parent 4b0cac8fb6
commit 405ac0254e
2 changed files with 17 additions and 15 deletions

View File

@ -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
@ -68,9 +60,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."""
@ -353,8 +342,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)

View File

@ -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)