blob: fbe44592416aca43ff5d0aa238e3bf830a5e2799 [file] [log] [blame]
Takashi Matsuo30125122015-08-19 11:42:32 -07001# Copyright 2014 Google Inc. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15"""An abstract class for caching the discovery document."""
16
17import abc
18
19
20class Cache(object):
Bu Sun Kim66bb32c2019-10-30 10:11:58 -070021 """A base abstract cache class."""
Takashi Matsuo30125122015-08-19 11:42:32 -070022
Bu Sun Kim66bb32c2019-10-30 10:11:58 -070023 __metaclass__ = abc.ABCMeta
24
25 @abc.abstractmethod
26 def get(self, url):
27 """Gets the content from the memcache with a given key.
Takashi Matsuo30125122015-08-19 11:42:32 -070028
29 Args:
30 url: string, the key for the cache.
31
32 Returns:
33 object, the value in the cache for the given key, or None if the key is
34 not in the cache.
35 """
Bu Sun Kim66bb32c2019-10-30 10:11:58 -070036 raise NotImplementedError()
Takashi Matsuo30125122015-08-19 11:42:32 -070037
Bu Sun Kim66bb32c2019-10-30 10:11:58 -070038 @abc.abstractmethod
39 def set(self, url, content):
40 """Sets the given key and content in the cache.
Takashi Matsuo30125122015-08-19 11:42:32 -070041
42 Args:
43 url: string, the key for the cache.
44 content: string, the discovery document.
45 """
Bu Sun Kim66bb32c2019-10-30 10:11:58 -070046 raise NotImplementedError()