From d0a6789fe2b115b67f70549516920e3b405291ab Mon Sep 17 00:00:00 2001 From: Ulan Djamanbalaev Date: Thu, 4 Dec 2014 11:58:30 +0600 Subject: [PATCH] catch exception on non-existing keys when cache.get and cache.delete --- README.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7b9e144..eee2d26 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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