--- a/src/pyams_cache/handler/memcached.py Mon Dec 11 15:26:55 2017 +0100
+++ b/src/pyams_cache/handler/memcached.py Sun Jan 14 12:23:07 2018 +0100
@@ -65,8 +65,8 @@
ip, port = server.split(':')
self.client = MemcachedClient(ip, int(port))
- def get(self, key, default=None):
- yield from self.client.get(key, default)
+ async def get(self, key, default=None):
+ return await self.client.get(key, default)
- def set(self, key, value):
- yield from self.client.set(key, value)
+ async def set(self, key, value):
+ await self.client.set(key, value)
--- a/src/pyams_cache/handler/redis.py Mon Dec 11 15:26:55 2017 +0100
+++ b/src/pyams_cache/handler/redis.py Sun Jan 14 12:23:07 2018 +0100
@@ -66,10 +66,15 @@
ip, port = server.split(':')
self.connection = ip, int(port)
- def get(self, key, default=None):
- connection = yield from aioredis.create_connection(self.connection)
- yield from connection.execute('get', key)
+ async def get(self, key, default=None):
+ connection = await aioredis.create_connection(self.connection)
+ value = await connection.execute('get', key)
+ connection.close()
+ await connection.wait_closed()
+ return value
- def set(self, key, value):
- connection = yield from aioredis.create_connection(self.connection)
- yield from connection.execute('set', key, value)
+ async def set(self, key, value):
+ connection = await aioredis.create_connection(self.connection)
+ await connection.execute('set', key, value)
+ connection.close()
+ await connection.wait_closed()