How to use the diskcache.fanout.FanoutCache function in diskcache

To help you get started, we’ve selected a few diskcache examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github grantjenks / python-diskcache / diskcache / fanout.py View on Github external
except KeyError:
            parts = name.split('/')
            directory = op.join(self._directory, 'index', *parts)
            temp = Index(directory)
            _indexes[name] = temp
            return temp


############################################################################
# BEGIN Python 2/3 Shims
############################################################################

if sys.hexversion < 0x03000000:
    import types
    memoize_func = Cache.__dict__['memoize']  # pylint: disable=invalid-name
    FanoutCache.memoize = types.MethodType(memoize_func, None, FanoutCache)
else:
    FanoutCache.memoize = Cache.memoize
github grantjenks / python-diskcache / diskcache / djangocache.py View on Github external
def __init__(self, directory, params):
        """Initialize DjangoCache instance.

        :param str directory: cache directory
        :param dict params: cache parameters

        """
        super(DjangoCache, self).__init__(params)
        shards = params.get('SHARDS', 8)
        timeout = params.get('DATABASE_TIMEOUT', 0.025)
        options = params.get('OPTIONS', {})
        self._cache = FanoutCache(directory, shards, timeout, **options)
github grantjenks / python-diskcache / diskcache / djangocache.py View on Github external
def __init__(self, directory, params):
        """Initialize DjangoCache instance.

        :param str directory: cache directory
        :param dict params: cache parameters

        """
        super(DjangoCache, self).__init__(params)
        shards = params.get('SHARDS', 8)
        timeout = params.get('DATABASE_TIMEOUT', 0.010)
        options = params.get('OPTIONS', {})
        self._cache = FanoutCache(directory, shards, timeout, **options)