Updated example with cache example. Removed debug statement.
authorJosh Roesslein <jroesslein@gmail.com>
Thu, 30 Jul 2009 07:49:50 +0000 (02:49 -0500)
committerJosh Roesslein <jroesslein@gmail.com>
Thu, 30 Jul 2009 07:49:50 +0000 (02:49 -0500)
TODO
example.py
tweepy/binder.py

diff --git a/TODO b/TODO
index c7eb3f9122e4884158cfa620059b12ce09e489a3..d0c0260e402edaac124de180c254219808da7e11 100644 (file)
--- a/TODO
+++ b/TODO
@@ -4,3 +4,4 @@ Stuff that needs to be done...
 - oauth support
 - search API
 - caching system
+    + in-memory cache done. now just need a file-based cache (pickle?)
index 547bbe75fa0f1653601d556ad1c430ca8292e4c3..6acdefa3ef404e21ffa5ed9177831266ba28feee 100644 (file)
@@ -25,3 +25,13 @@ print 'Update: %s' % update.text
 # Get the timeline for the 'twitter' user.
 twitter_timeline = api.user_timeline(screen_name='twitter')
 
+# You can also setup up a cache.
+# Here we will use an in-memory cache with a timeout of 60 seconds.
+cached_api = tweepy.API(username, password, cache=tweepy.MemoryCache(timeout=60))
+
+# First request here will not be cached
+s = cached_api.get_status(id=123)
+
+# Now this request will be cached and won't require a trip to twitter's server.
+s_again = cached_api.get_status(id=123)
+
index 78aaa230e1efbcceb737a21562ba8953e2a110ef..02c35d4c37b7de9746024fae7f367cbba9073282 100644 (file)
@@ -33,7 +33,6 @@ def bind_api(path, parser, allowed_param=None, method='GET', require_auth=False,
       cache_result = api.cache.get(url, timeout)
       if cache_result:
         # if cache result found and not expired, return it
-        print 'hit!!!!'
         return cache_result
 
     # Open connection