Debian Codegraph @

googleapiclient/discovery_cache/base.py

raw
1 # 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
17 import abc
18
19
20 class Cache(object):
21 """A base abstract cache class."""
22
23 __metaclass__ = abc.ABCMeta
24
25 @abc.abstractmethod
26 def get(self, url):
27 """Gets the content from the memcache with a given key.
28
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 """
36 raise NotImplementedError()
37
38 @abc.abstractmethod
39 def set(self, url, content):
40 """Sets the given key and content in the cache.
41
42 Args:
43 url: string, the key for the cache.
44 content: string, the discovery document.
45 """
46 raise NotImplementedError()