Skip to content

Instantly share code, notes, and snippets.

@whitekid
Created August 13, 2015 08:17
Show Gist options
  • Save whitekid/25dd5b6774ff6c786f14 to your computer and use it in GitHub Desktop.
Save whitekid/25dd5b6774ff6c786f14 to your computer and use it in GitHub Desktop.
oslo.cache
import unittest
import oslo_cache.core as cache
from oslo_config import cfg
CONF = cfg.CONF
class CacheTest(unittest.TestCase):
def get_client(self):
cache.configure(CONF)
# setup cache option
CONF.set_override('enabled', True, 'cache')
CONF.set_override('backend', 'oslo_cache.memcache_pool', 'cache')
CONF.set_override('memcache_servers', ['your-memcache-server:11211'], 'cache')
region = cache.create_region()
cache.configure_cache_region(CONF, region)
return region
def test_cache(self):
client = self.get_client()
client.set('xxx', 'value')
self.assertEquals('value', client.get('xxx'))
if __name__ == '__main__':
unittest.main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment