2014-11-01 19:34:14 +00:00
|
|
|
# (c) 2014, Brian Coca, Josh Drake, et al
|
|
|
|
#
|
|
|
|
# This file is part of Ansible
|
|
|
|
#
|
|
|
|
# Ansible is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# Ansible is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
2015-04-15 17:09:59 +00:00
|
|
|
|
2015-04-13 20:28:01 +00:00
|
|
|
from __future__ import (absolute_import, division, print_function)
|
|
|
|
__metaclass__ = type
|
2014-11-01 19:34:14 +00:00
|
|
|
|
2015-04-15 17:09:59 +00:00
|
|
|
from abc import ABCMeta, abstractmethod
|
|
|
|
|
2015-10-16 00:55:23 +00:00
|
|
|
from ansible.compat.six import with_metaclass
|
2015-04-15 17:09:59 +00:00
|
|
|
|
2015-07-23 14:24:50 +00:00
|
|
|
try:
|
|
|
|
from __main__ import display
|
|
|
|
except ImportError:
|
|
|
|
from ansible.utils.display import Display
|
|
|
|
display = Display()
|
|
|
|
|
2014-11-01 19:34:14 +00:00
|
|
|
|
2015-06-03 20:27:31 +00:00
|
|
|
class BaseCacheModule(with_metaclass(ABCMeta, object)):
|
2014-11-01 19:34:14 +00:00
|
|
|
|
2015-11-11 18:19:58 +00:00
|
|
|
# Backwards compat only. Just import the global display instead
|
2015-10-12 17:03:49 +00:00
|
|
|
_display = display
|
2015-07-23 14:24:50 +00:00
|
|
|
|
2015-04-15 17:09:59 +00:00
|
|
|
@abstractmethod
|
2014-11-01 19:34:14 +00:00
|
|
|
def get(self, key):
|
2015-04-15 17:09:59 +00:00
|
|
|
pass
|
2014-11-01 19:34:14 +00:00
|
|
|
|
2015-04-15 17:09:59 +00:00
|
|
|
@abstractmethod
|
2014-11-01 19:34:14 +00:00
|
|
|
def set(self, key, value):
|
2015-04-15 17:09:59 +00:00
|
|
|
pass
|
2014-11-01 19:34:14 +00:00
|
|
|
|
2015-04-15 17:09:59 +00:00
|
|
|
@abstractmethod
|
2014-11-01 19:34:14 +00:00
|
|
|
def keys(self):
|
2015-04-15 17:09:59 +00:00
|
|
|
pass
|
2014-11-01 19:34:14 +00:00
|
|
|
|
2015-04-15 17:09:59 +00:00
|
|
|
@abstractmethod
|
2014-11-01 19:34:14 +00:00
|
|
|
def contains(self, key):
|
2015-04-15 17:09:59 +00:00
|
|
|
pass
|
2014-11-01 19:34:14 +00:00
|
|
|
|
2015-04-15 17:09:59 +00:00
|
|
|
@abstractmethod
|
2014-11-01 19:34:14 +00:00
|
|
|
def delete(self, key):
|
2015-04-15 17:09:59 +00:00
|
|
|
pass
|
2014-11-01 19:34:14 +00:00
|
|
|
|
2015-04-15 17:09:59 +00:00
|
|
|
@abstractmethod
|
2014-11-01 19:34:14 +00:00
|
|
|
def flush(self):
|
2015-04-15 17:09:59 +00:00
|
|
|
pass
|
2014-11-01 19:34:14 +00:00
|
|
|
|
2015-04-15 17:09:59 +00:00
|
|
|
@abstractmethod
|
2014-11-01 19:34:14 +00:00
|
|
|
def copy(self):
|
2015-04-15 17:09:59 +00:00
|
|
|
pass
|
2015-05-08 02:14:16 +00:00
|
|
|
|