Skip to content

Commit

Permalink
added __contains__
Browse files Browse the repository at this point in the history
  • Loading branch information
atl committed May 27, 2010
1 parent 791dc62 commit c1ed1f0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion redish/proxy.py
Expand Up @@ -48,7 +48,10 @@ def __init__(self, **kwargs):
The `miss` argument accepts a function of one argument to which
it passes a key, if the key is unknown in the datastore. By default
it returns a "None". Another possibility for more strict checking
is passing in a KeyError.
is passing in a KeyError. If a user attempts to initialize a redis
key with an empty container, that container is kept in the (local
threading) proxy object so that subsequent accesses keep the
right type without throwing KeyErrors.
"""
try:
self.miss = kwargs.pop('miss')
Expand Down Expand Up @@ -102,3 +105,6 @@ def __setitem__(self, key, value):
pline = pline.zadd(key, k, v)
pline.execute()

def __contains__(self, key):
return self.exists(key) or key in self.empties

0 comments on commit c1ed1f0

Please sign in to comment.