2017-04-06 19:05:51 +03:00
|
|
|
"""Example hierarchy of cache clients with abstract base class."""
|
|
|
|
|
|
|
|
|
2020-01-27 02:41:36 +03:00
|
|
|
class AbstractCacheClient:
|
2017-04-06 19:05:51 +03:00
|
|
|
"""Abstract cache client."""
|
|
|
|
|
|
|
|
|
|
|
|
class RedisCacheClient(AbstractCacheClient):
|
|
|
|
"""Cache client implementation based on Redis."""
|
|
|
|
|
|
|
|
def __init__(self, host, port, db):
|
2020-01-26 22:22:43 +03:00
|
|
|
"""Initialize instance."""
|
2017-04-06 19:05:51 +03:00
|
|
|
self.host = host
|
|
|
|
self.port = port
|
|
|
|
self.db = db
|
|
|
|
|
|
|
|
|
|
|
|
class MemcacheCacheClient(AbstractCacheClient):
|
|
|
|
"""Cache client implementation based on Memcached."""
|
|
|
|
|
|
|
|
def __init__(self, hosts, port, prefix):
|
2020-01-26 22:22:43 +03:00
|
|
|
"""Initialize instance."""
|
2017-04-06 19:05:51 +03:00
|
|
|
self.hosts = hosts
|
|
|
|
self.port = port
|
|
|
|
self.prefix = prefix
|