U
    ‰di  ã                   @   sH   d Z ddlmZ ddlmZ ddlmZ ddlmZ G dd„ deƒZ	dS )	z6Celery cache backend using the Django Cache Framework.é    )ÚKeyValueStoreBackend)Úcache)Úcaches)Úbytes_to_strc                       sT   e Zd ZdZ‡ fdd„Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	e
dd„ ƒZ‡  ZS )ÚCacheBackendz@Backend using the Django cache framework to store task metadata.c                    s   t ƒ j||Ž d| _d S )NÚpickle)ÚsuperÚ__init__Ú
serializer)ÚselfÚargsÚkwargs©Ú	__class__© úH/tmp/pip-unpacked-wheel-oj8imec1/django_celery_results/backends/cache.pyr	      s    zCacheBackend.__init__c                 C   s   t |ƒ}| j |¡S ©N)r   Úcache_backendÚget©r   Úkeyr   r   r   r      s    zCacheBackend.getc                 C   s   t |ƒ}| j ||| j¡ d S r   )r   r   ÚsetÚexpires)r   r   Úvaluer   r   r   r      s    zCacheBackend.setc                 C   s   t |ƒ}| j |¡ d S r   )r   r   Údeleter   r   r   r   r      s    zCacheBackend.deletec                 C   s   |S r   r   ©r   Údatar   r   r   Úencode   s    zCacheBackend.encodec                 C   s   |S r   r   r   r   r   r   Údecode!   s    zCacheBackend.decodec                 C   s   | j jj}|rt| S tS r   )ZappÚconfr   r   Údefault_cache)r   Úbackendr   r   r   r   $   s    
zCacheBackend.cache_backend)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r	   r   r   r   r   r   Úpropertyr   Ú__classcell__r   r   r   r   r   	   s   r   N)
r%   Zcelery.backends.baser   Zdjango.core.cacher   r    r   Zkombu.utils.encodingr   r   r   r   r   r   Ú<module>   s
   