Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 # Use of this source code is governed by a BSD-style license that can be | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 5 | |
| 6 class Cache(object): | |
| 7 """An interface to cache and retrieve data. | |
| 8 | |
| 9 Subclasses should implement the Get/Set functions. | |
| 10 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.
| |
| 11 """ | |
| 12 def Get(self, key): | |
| 13 """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
| |
| 14 | |
| 15 Args: | |
| 16 key (str): The key to identify the cached data. | |
| 17 """ | |
| 18 raise NotImplementedError() | |
| 19 | |
| 20 def Set(self, key, data, expire_time=0): | |
| 21 """Cache the given data which is identified by the given key. | |
| 22 | |
| 23 Args: | |
| 24 key (str): The key to identify the cached data. | |
| 25 data (object): The python object to be cached. | |
| 26 expire_time (int): Number of seconds from current time (up to 1 month). | |
| 27 """ | |
| 28 raise NotImplementedError() | |
| OLD | NEW |