mirror of
				https://github.com/ets-labs/python-dependency-injector.git
				synced 2025-11-04 09:57:37 +03:00 
			
		
		
		
	
		
			
				
	
	
		
			26 lines
		
	
	
		
			647 B
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			26 lines
		
	
	
		
			647 B
		
	
	
	
		
			Python
		
	
	
	
	
	
"""Example hierarchy of cache clients with abstract base class."""
 | 
						|
 | 
						|
 | 
						|
class AbstractCacheClient:
 | 
						|
    """Abstract cache client."""
 | 
						|
 | 
						|
 | 
						|
class RedisCacheClient(AbstractCacheClient):
 | 
						|
    """Cache client implementation based on Redis."""
 | 
						|
 | 
						|
    def __init__(self, host, port, db):
 | 
						|
        """Initialize instance."""
 | 
						|
        self.host = host
 | 
						|
        self.port = port
 | 
						|
        self.db = db
 | 
						|
 | 
						|
 | 
						|
class MemcacheCacheClient(AbstractCacheClient):
 | 
						|
    """Cache client implementation based on Memcached."""
 | 
						|
 | 
						|
    def __init__(self, hosts, port, prefix):
 | 
						|
        """Initialize instance."""
 | 
						|
        self.hosts = hosts
 | 
						|
        self.port = port
 | 
						|
        self.prefix = prefix
 |