Change dogpile cache defaults

Memory cache can grow unbounded, so it should really be opt in. Change
to match shade with the following defaults:
 - If you specify nothing, you get null cache
 - If you specify an expiration time and nothing else, you get memory
   cache
 - If you specify an explicit cache class, you will get that class

Change-Id: I6c9eab71a88a534de7e52ad2a564450c44aacc1d
This commit is contained in:
Monty Taylor 2015-03-06 08:21:43 -05:00
parent d5931d4658
commit 63e1630f2b
2 changed files with 15 additions and 5 deletions

View File

@ -112,13 +112,21 @@ Cache Settings
Accessing a cloud is often expensive, so it's quite common to want to do some
client-side caching of those operations. To facilitate that, os-client-config
understands a simple set of cache control settings.
understands passing through cache settings to dogpile.cache, with the following
behaviors:
* Listing no config settings means you get a null cache.
* `cache.max_age` and nothing else gets you memory cache.
* Otherwise, `cache.class` and `cache.arguments` are passed in
::
cache:
path: ~/.cache/openstack
max_age: 300
class: dogpile.cache.pylibmc
max_age: 3600
arguments:
url:
- 127.0.0.1
clouds:
mordred:
cloud: hp

View File

@ -88,13 +88,15 @@ class OpenStackConfig(object):
self.cloud_config = dict(
clouds=dict(openstack=dict(self.defaults)))
self._cache_max_age = 300
self._cache_max_age = None
self._cache_path = CACHE_PATH
self._cache_class = 'dogpile.cache.memory'
self._cache_class = 'dogpile.cache.null'
self._cache_arguments = {}
if 'cache' in self.cloud_config:
self._cache_max_age = self.cloud_config['cache'].get(
'max_age', self._cache_max_age)
if self._cache_max_age:
self._cache_class = 'dogpile.cache.memory'
self._cache_path = os.path.expanduser(
self.cloud_config['cache'].get('path', self._cache_path))
self._cache_class = self.cloud_config['cache'].get(