summaryrefslogtreecommitdiff
path: root/dogpile/cache/backends/null.py
blob: c1f46a9d6d14fe85cfbc1ce8ce63cc0a33b779b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""
Null Backend
-------------

The Null backend does not do any caching at all.  It can be
used to test behavior without caching, or as a means of disabling
caching for a region that is otherwise used normally.

.. versionadded:: 0.5.4

"""

from dogpile.cache.api import CacheBackend, NO_VALUE


__all__ = ['NullBackend']


class NullLock(object):
    def acquire(self):
        pass

    def release(self):
        pass


class NullBackend(CacheBackend):
    """A "null" backend that effectively disables all cache operations.

    Basic usage::

        from dogpile.cache import make_region

        region = make_region().configure(
            'dogpile.cache.null'
        )

    """

    def __init__(self, arguments):
        pass

    def get_mutex(self, key):
        return NullLock()

    def get(self, key):
        return NO_VALUE

    def get_multi(self, keys):
        return [NO_VALUE for k in keys]

    def set(self, key, value):
        pass

    def set_multi(self, mapping):
        pass

    def delete(self, key):
        pass

    def delete_multi(self, keys):
        pass