1# (c) 2014, Brian Coca, Josh Drake, et al
2# (c) 2017 Ansible Project
3# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
4
5
6from __future__ import (absolute_import, division, print_function)
7__metaclass__ = type
8
9from ansible.plugins.cache import BaseCacheModule
10
11DOCUMENTATION = '''
12    cache: none
13    short_description: write-only cache (no cache)
14    description:
15        - No caching at all
16    version_added: historical
17    author: core team (@ansible-core)
18    options:
19      _timeout:
20        default: 86400
21        description: Expiration timeout for the cache plugin data
22        env:
23          - name: ANSIBLE_CACHE_PLUGIN_TIMEOUT
24        ini:
25          - key: fact_caching_timeout
26            section: defaults
27        type: integer
28'''
29
30
31class CacheModule(BaseCacheModule):
32    def __init__(self, *args, **kwargs):
33        super(CacheModule, self).__init__(*args, **kwargs)
34        self.empty = {}
35        self._timeout = self.get_option('_timeout')
36
37    def get(self, key):
38        return self.empty.get(key)
39
40    def set(self, key, value):
41        return value
42
43    def keys(self):
44        return self.empty.keys()
45
46    def contains(self, key):
47        return key in self.empty
48
49    def delete(self, key):
50        del self.emtpy[key]
51
52    def flush(self):
53        self.empty = {}
54
55    def copy(self):
56        return self.empty.copy()
57
58    def __getstate__(self):
59        return self.copy()
60
61    def __setstate__(self, data):
62        self.empty = data
63