django-storages / storages / backends /

The default branch has multiple heads

from queued_storage.backend import QueuedRemoteStorage
import logging

from django.conf import settings

from redis import Redis  # depends on Redis server

# Get an instance of a logger
logger = logging.getLogger(__name__)

REDIS = getattr(settings, 'REDIS', None)
REMOTE = "remote"  # local const

class MokaStorage(QueuedRemoteStorage):
    """Moka custom storage."""

    def __init__(self):"Initializing storage: %s", self)
        super(MokaStorage, self).__init__(

        self._redis = Redis(**settings.REDIS["storage"])"Connection to redis is now active: %s", self._redis)

    def get_storage(self, name):
        cache_result = self._redis.sismember(REMOTE, name)

        if cache_result:
  "Cache hit for file '%s'", name)
            return self.remote

        elif self.remote.exists(name):
  "Caching remote storage for file '%s'", name)
            self._redis.sadd(REMOTE, name)
            return self.remote"File '%s' was not found on the remote resource", name)
        return self.local