Merge "Remove NoOp cache from oslo.cache"
This commit is contained in:
commit
b480848c37
|
@ -35,7 +35,7 @@ FILE_OPTIONS = {
|
||||||
# prevent issues with the memory cache ending up in "production"
|
# prevent issues with the memory cache ending up in "production"
|
||||||
# unintentionally, we register a no-op as the keystone default caching
|
# unintentionally, we register a no-op as the keystone default caching
|
||||||
# backend.
|
# backend.
|
||||||
cfg.StrOpt('backend', default='oslo_cache.noop',
|
cfg.StrOpt('backend', default='dogpile.cache.null',
|
||||||
help='Dogpile.cache backend module. It is recommended '
|
help='Dogpile.cache backend module. It is recommended '
|
||||||
'that Memcache with pooling '
|
'that Memcache with pooling '
|
||||||
'(oslo_cache.memcache_pool) or Redis '
|
'(oslo_cache.memcache_pool) or Redis '
|
||||||
|
|
|
@ -1,54 +0,0 @@
|
||||||
# Copyright 2013 Metacloud
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
||||||
# not use this file except in compliance with the License. You may obtain
|
|
||||||
# a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
# License for the specific language governing permissions and limitations
|
|
||||||
# under the License.
|
|
||||||
|
|
||||||
from dogpile.cache import api
|
|
||||||
from oslo_cache import core
|
|
||||||
|
|
||||||
|
|
||||||
__all__ = [
|
|
||||||
'NoopCacheBackend'
|
|
||||||
]
|
|
||||||
|
|
||||||
_NO_VALUE = core.NO_VALUE
|
|
||||||
|
|
||||||
|
|
||||||
class NoopCacheBackend(api.CacheBackend):
|
|
||||||
"""A no op backend as a default caching backend.
|
|
||||||
|
|
||||||
The no op backend is provided as the default caching backend for keystone
|
|
||||||
to ensure that ``dogpile.cache.memory`` is not used in any real-world
|
|
||||||
circumstances unintentionally. ``dogpile.cache.memory`` does not have a
|
|
||||||
mechanism to cleanup it's internal dict and therefore could cause run-away
|
|
||||||
memory utilization.
|
|
||||||
"""
|
|
||||||
def __init__(self, *args):
|
|
||||||
return
|
|
||||||
|
|
||||||
def get(self, key):
|
|
||||||
return _NO_VALUE
|
|
||||||
|
|
||||||
def get_multi(self, keys):
|
|
||||||
return [_NO_VALUE for x in keys]
|
|
||||||
|
|
||||||
def set(self, key, value):
|
|
||||||
return
|
|
||||||
|
|
||||||
def set_multi(self, mapping):
|
|
||||||
return
|
|
||||||
|
|
||||||
def delete(self, key):
|
|
||||||
return
|
|
||||||
|
|
||||||
def delete_multi(self, keys):
|
|
||||||
return
|
|
|
@ -333,32 +333,3 @@ class UTF8KeyManglerTests(BaseTestCase):
|
||||||
key = 'fake'
|
key = 'fake'
|
||||||
encoded = cache._sha1_mangle_key(key)
|
encoded = cache._sha1_mangle_key(key)
|
||||||
self.assertIsNotNone(encoded)
|
self.assertIsNotNone(encoded)
|
||||||
|
|
||||||
|
|
||||||
class CacheNoopBackendTest(BaseTestCase):
|
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
super(CacheNoopBackendTest, self).setUp()
|
|
||||||
self.config_fixture.config(group='cache',
|
|
||||||
backend='oslo_cache.noop')
|
|
||||||
|
|
||||||
self.region = cache.create_region()
|
|
||||||
cache.configure_cache_region(self.config_fixture.conf, self.region)
|
|
||||||
|
|
||||||
def test_noop_backend(self):
|
|
||||||
single_value = 'Test Value'
|
|
||||||
single_key = 'testkey'
|
|
||||||
multi_values = {'key1': 1, 'key2': 2, 'key3': 3}
|
|
||||||
|
|
||||||
self.region.set(single_key, single_value)
|
|
||||||
self.assertEqual(NO_VALUE, self.region.get(single_key))
|
|
||||||
|
|
||||||
self.region.set_multi(multi_values)
|
|
||||||
cached_values = self.region.get_multi(multi_values.keys())
|
|
||||||
self.assertEqual(len(cached_values), len(multi_values.values()))
|
|
||||||
for value in cached_values:
|
|
||||||
self.assertEqual(NO_VALUE, value)
|
|
||||||
|
|
||||||
# Delete should not raise exceptions
|
|
||||||
self.region.delete(single_key)
|
|
||||||
self.region.delete_multi(multi_values.keys())
|
|
||||||
|
|
Loading…
Reference in New Issue