Remove NoOp cache from oslo.cache

dogpile v.0.5.4 supports Null backend that does nothing.
This functionality is the same as NoOp backend in oslo.cache.
So we can delete NoOp backend from oslo.cache and use
Null backend by default.

Change-Id: If676d64e8a56a689679e83670ce252ef2793949f
This commit is contained in:
kairat_kushaev 2015-07-27 18:25:05 +03:00
parent 098b434d3d
commit d1c7d0628c
4 changed files with 2 additions and 85 deletions

View File

@ -35,7 +35,7 @@ FILE_OPTIONS = {
# prevent issues with the memory cache ending up in "production"
# unintentionally, we register a no-op as the keystone default caching
# backend.
cfg.StrOpt('backend', default='oslo_cache.noop',
cfg.StrOpt('backend', default='dogpile.cache.null',
help='Dogpile.cache backend module. It is recommended '
'that Memcache with pooling '
'(oslo_cache.memcache_pool) or Redis '

View File

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

View File

@ -333,32 +333,3 @@ class UTF8KeyManglerTests(BaseTestCase):
key = 'fake'
encoded = cache._sha1_mangle_key(key)
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())

View File

@ -3,7 +3,7 @@
# process, which may cause wedges in the gate later.
Babel>=1.3
dogpile.cache>=0.5.3
dogpile.cache>=0.5.4
six>=1.9.0
oslo.config>=1.11.0 # Apache-2.0
oslo.i18n>=1.5.0 # Apache-2.0