コード例 #1
0
ファイル: _cache.py プロジェクト: williamwang0/MusicGen
 def __init__(self, memcache_servers, arguments, **kwargs):
     # NOTE(sileht): This will import python-memcached, we don't want
     # it as hard dependency, so lazy load it.
     from oslo_cache import _memcache_pool
     self._pool = _memcache_pool.MemcacheClientPool(memcache_servers,
                                                    arguments,
                                                    **kwargs)
コード例 #2
0
 def test_memcache_client_pool_create_connection(self):
     urls = [
         "foo",
         "http://foo",
         "http://bar:11211",
         "http://bar:8080",
         "https://[2620:52:0:13b8:5054:ff:fe3e:1]:8080",
         # testing port format is already in use in ipv6 format
         "https://[2620:52:0:13b8:8080:ff:fe3e:1]:8080",
         "https://[2620:52:0:13b8:5054:ff:fe3e:1]",
         "https://[::192.9.5.5]",
     ]
     mcp = _memcache_pool.MemcacheClientPool(urls=urls,
                                             arguments={},
                                             maxsize=10,
                                             unused_timeout=10)
     mc = mcp._create_connection()
     self.assertTrue(type(mc) is pymemcache_hash.HashClient)
     self.assertTrue("foo:11211" in mc.clients)
     self.assertTrue("http://foo:11211" in mc.clients)
     self.assertTrue("http://bar:11211" in mc.clients)
     self.assertTrue("http://bar:8080" in mc.clients)
     self.assertTrue(
         "https://[2620:52:0:13b8:5054:ff:fe3e:1]:8080" in mc.clients)
     self.assertTrue(
         "https://[2620:52:0:13b8:8080:ff:fe3e:1]:8080" in mc.clients)
     self.assertTrue(
         "https://[2620:52:0:13b8:5054:ff:fe3e:1]:11211" in mc.clients)
     self.assertTrue("https://[::192.9.5.5]:11211" in mc.clients)
コード例 #3
0
 def __init__(self, arguments):
     super(PooledMemcachedBackend, self).__init__(arguments)
     self.client_pool = _memcache_pool.MemcacheClientPool(
         self.url,
         arguments={
             'dead_retry': arguments.get('dead_retry', 5 * 60),
             'socket_timeout': arguments.get('socket_timeout', 3),
         },
         maxsize=arguments.get('pool_maxsize', 10),
         unused_timeout=arguments.get('pool_unused_timeout', 60),
         conn_get_timeout=arguments.get('pool_connection_get_timeout', 10),
     )