Chromium Code Reviews| Index: appengine/findit/lib/cache.py |
| diff --git a/appengine/findit/lib/cache.py b/appengine/findit/lib/cache.py |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..e5da69b2345e4cb87253a3eb795c64512024c0be |
| --- /dev/null |
| +++ b/appengine/findit/lib/cache.py |
| @@ -0,0 +1,28 @@ |
| +# Copyright 2016 The Chromium Authors. All rights reserved. |
| +# Use of this source code is governed by a BSD-style license that can be |
| +# found in the LICENSE file. |
| + |
| + |
| +class Cache(object): |
| + """An interface to cache and retrieve data. |
| + |
| + Subclasses should implement the Get/Set functions. |
| + TODO: Add a Delete function (default to no-op) if needed later. |
|
wrengr
2016/12/06 21:52:57
I'd consider settable(-only) caches to be a differ
Sharu Jiang
2016/12/06 23:58:17
Acknowledged.
|
| + """ |
| + def Get(self, key): |
| + """Returns the cached data for the given key if available. |
|
wrengr
2016/12/06 21:52:57
There should be more description about what the ex
Sharu Jiang
2016/12/06 23:58:17
Good question, but I think this function just have
|
| + |
| + Args: |
| + key (str): The key to identify the cached data. |
| + """ |
| + raise NotImplementedError() |
| + |
| + def Set(self, key, data, expire_time=0): |
| + """Cache the given data which is identified by the given key. |
| + |
| + Args: |
| + key (str): The key to identify the cached data. |
| + data (object): The python object to be cached. |
| + expire_time (int): Number of seconds from current time (up to 1 month). |
| + """ |
| + raise NotImplementedError() |