Move memcached_servers opt into common.memorycache
Add a factory function to nova.common.memorycache which consolidates the code to choose between real or fake memcache. This then means that memcached_servers is used in just one place and we can move the config option there. blueprint: scope-config-opts Change-Id: I67c191e0db58364eda4162b9e881606063509b9d
This commit is contained in:
@@ -18,8 +18,28 @@
|
||||
|
||||
"""Super simple fake memcache client."""
|
||||
|
||||
from nova.openstack.common import cfg
|
||||
from nova.openstack.common import timeutils
|
||||
|
||||
memcache_opts = [
|
||||
cfg.ListOpt('memcached_servers',
|
||||
default=None,
|
||||
help='Memcached servers or None for in process cache.'),
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts(memcache_opts)
|
||||
|
||||
|
||||
def get_client():
|
||||
client_cls = Client
|
||||
|
||||
if CONF.memcached_servers:
|
||||
import memcache
|
||||
client_cls = memcache.Client
|
||||
|
||||
return client_cls(CONF.memcached_servers, debug=0)
|
||||
|
||||
|
||||
class Client(object):
|
||||
"""Replicates a tiny subset of memcached client interface."""
|
||||
|
||||
Reference in New Issue
Block a user