From d1c7d0628c1080a743ea3d6f2042549b8e51d5a3 Mon Sep 17 00:00:00 2001 From: kairat_kushaev Date: Mon, 27 Jul 2015 18:25:05 +0300 Subject: [PATCH] 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 --- oslo_cache/_opts.py | 2 +- oslo_cache/backends/noop.py | 54 ---------------------------------- oslo_cache/tests/test_cache.py | 29 ------------------ requirements.txt | 2 +- 4 files changed, 2 insertions(+), 85 deletions(-) delete mode 100644 oslo_cache/backends/noop.py diff --git a/oslo_cache/_opts.py b/oslo_cache/_opts.py index 9ccf878d..1ffbb2d1 100644 --- a/oslo_cache/_opts.py +++ b/oslo_cache/_opts.py @@ -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 ' diff --git a/oslo_cache/backends/noop.py b/oslo_cache/backends/noop.py deleted file mode 100644 index 7fdea4ef..00000000 --- a/oslo_cache/backends/noop.py +++ /dev/null @@ -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 diff --git a/oslo_cache/tests/test_cache.py b/oslo_cache/tests/test_cache.py index 450019bc..698fd4fe 100644 --- a/oslo_cache/tests/test_cache.py +++ b/oslo_cache/tests/test_cache.py @@ -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()) diff --git a/requirements.txt b/requirements.txt index d2bd1d57..7262e682 100644 --- a/requirements.txt +++ b/requirements.txt @@ -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