Skip to content

Commit

Permalink
Added and clarified some code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
ericflo committed Jul 15, 2010
1 parent a6e96a6 commit fe0145d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion newcache.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ def _get_memcache_timeout(self, timeout):
return timeout

def add(self, key, value, timeout=None, herd=True):
# If the user chooses to use the herd mechanism, then encode some
# timestamp information into the object to be persisted into memcached
if herd:
packed = (value,
(timeout or self.default_timeout) + int(time.time()))
Expand Down Expand Up @@ -123,6 +125,8 @@ def get(self, key, default=None):
return val

def set(self, key, value, timeout=None, herd=True):
# If the user chooses to use the herd mechanism, then encode some
# timestamp information into the object to be persisted into memcached
if herd:
packed = (value,
(timeout or self.default_timeout) + int(time.time()))
Expand Down Expand Up @@ -175,7 +179,8 @@ def get_many(self, keys):
self._get_memcache_timeout(CACHE_HERD_TIMEOUT))

# Build a reverse map of encoded keys to the original keys, so that
# the dictionary keys are what users expect.
# the returned dict's keys are what users expect (in that they match
# what the user originally entered)
reverse = dict(zip(rvals, keys))

return dict(((reverse[k], v) for k, v in resp.iteritems()))
Expand Down

0 comments on commit fe0145d

Please sign in to comment.