Skip to content

Commit

Permalink
catch exception on non-existing keys when cache.get and cache.delete
Browse files Browse the repository at this point in the history
  • Loading branch information
ulandj committed Dec 4, 2014
1 parent 88f5040 commit d0a6789
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ print item.value
from iron_cache import *

cache = IronCache()
item = cache.get(cache="test_cache", key="mykey")
print item.value
try:
item = cache.get(cache="test_cache", key="mykey")
except:
item = None
print item.value if item else print None
```

### Increment an Item's Value
Expand All @@ -70,7 +73,10 @@ cache.increment(cache="test_cache", key="mykey", amount=10)
from iron_cache import *

cache = IronCache()
cache.delete(cache="test_cache", key="mykey")
try:
cache.delete(cache="test_cache", key="mykey")
except:
pass
```

## License
Expand Down

0 comments on commit d0a6789

Please sign in to comment.