From 5e0069df6ce9930a4a8ae658b31f70c75766186e Mon Sep 17 00:00:00 2001 From: Josh Roesslein Date: Thu, 30 Jul 2009 02:49:50 -0500 Subject: [PATCH] Updated example with cache example. Removed debug statement. --- TODO | 1 + example.py | 10 ++++++++++ tweepy/binder.py | 1 - 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index c7eb3f9..d0c0260 100644 --- 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?) diff --git a/example.py b/example.py index 547bbe7..6acdefa 100644 --- a/example.py +++ b/example.py @@ -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) + diff --git a/tweepy/binder.py b/tweepy/binder.py index 78aaa23..02c35d4 100644 --- a/tweepy/binder.py +++ b/tweepy/binder.py @@ -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 -- 2.25.1