-
Florent Aide authoredFlorent Aide authored
optimization.py 1.37 KiB
# import redis
#
#
#
#
# class Optimization(object):
#
# def __init__(self):
#
# db = redis.Redis('localhost')
#
# def save_distance(self, key, value):
# """Save a key with some data into Redis.
# """
#
# try:
# # unicode objects must be encoded before hashing so we encode to
# # utf-8
# # TODO ?? Where does this encoding happen?
# with (yield from self.redis_pool) as conn:
# yield from conn.set(key, info)
# except (aioredis.ReplyError, aioredis.ProtocolError):
# return False
# return True
#
#
# def get_key_info(self, key: str) -> str:
# """Retrieve data about a key from Redis, or None if unavailable.
# """
#
# try:
# with (yield from self.redis_pool) as conn:
# info = yield from conn.get(key)
# except (aioredis.ReplyError, aioredis.ProtocolError):
# return None
# if info is None:
# return None
# return info.decode("utf-8")
#
#
# def destroy_key(self, key: str) -> bool:
# try:
# with (yield from self.redis_pool) as conn:
# yield from conn.delete(key)
# except (aioredis.ReplyError, aioredis.ProtocolError):
# return False
# return True