From: Josh Roesslein Date: Wed, 4 Nov 2009 20:15:12 +0000 (-0600) Subject: Moved memcache implementation to extensions repository. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=28942ca8fe17359c40ae0778c6f2eb63acf214ec;p=tweepy.git Moved memcache implementation to extensions repository. --- diff --git a/CHANGES b/CHANGES index 7705520..91e2277 100644 --- a/CHANGES +++ b/CHANGES @@ -11,6 +11,7 @@ during upgrade will be listed here. + Moved documentation out of api.py and into wiki. + Removed 'email' parameter from API.update_profile. No longer supported. + API.auth_handler -> API.auth ++ Moved memcache implementation to tweepy-more repository. 1.1 -> 1.2 [Current] ===================== diff --git a/README b/README index 91fe7a9..9e47f80 100644 --- a/README +++ b/README @@ -12,7 +12,7 @@ Features: + Up-to-date with Twitter API + Actively under development + Streaming API support - + Cache system (memory, file, memcache) + + Cache system (memory, file) + Python 3 branch (3.1) Getting started: @@ -36,6 +36,7 @@ Installing: Souce code: Library: http://github.com/joshthecoder/tweepy Examples: http://github.com/joshthecoder/tweepy-examples + Extensions: http://github.com/joshthecoder/tweepy-more Author: Joshua Roesslein License: MIT @@ -45,6 +46,4 @@ Dependencies: **Included in python 2.6+ Python-OAuth **Bundled with this library - python-memcached - **Bundled with this library diff --git a/tests.py b/tests.py index ed50dc3..ee008ea 100644 --- a/tests.py +++ b/tests.py @@ -312,9 +312,6 @@ class TweepyCacheTests(unittest.TestCase): self.cache.flush() os.rmdir('cache_test_dir') - def testmemcache(self): - self.cache = MemCache(self.memcache_servers, self.timeout) - self._run_tests(do_cleanup=False) if __name__ == '__main__': diff --git a/tweepy/__init__.py b/tweepy/__init__.py index 8f15d9e..c54e709 100644 --- a/tweepy/__init__.py +++ b/tweepy/__init__.py @@ -12,7 +12,7 @@ __license__ = 'MIT' from tweepy.models import Status, User, DirectMessage, Friendship, SavedSearch, SearchResult, models from tweepy.error import TweepError from tweepy.api import API -from tweepy.cache import Cache, MemoryCache, FileCache, MemCache +from tweepy.cache import Cache, MemoryCache, FileCache from tweepy.auth import BasicAuthHandler, OAuthHandler from tweepy.streaming import Stream, StreamListener from tweepy.cursor import Cursor diff --git a/tweepy/cache.py b/tweepy/cache.py index 7740014..0d2d82f 100644 --- a/tweepy/cache.py +++ b/tweepy/cache.py @@ -20,8 +20,6 @@ except ImportError: # TODO: use win32file pass -from tweepy import memcache - class Cache(object): """Cache interface""" @@ -264,43 +262,3 @@ class FileCache(Cache): continue self._delete_file(os.path.join(self.cache_dir, entry)) - -class MemCache(Cache): - """Memcache client""" - - def __init__(self, servers, timeout=60): - Cache.__init__(self, timeout) - self.client = memcache.Client(servers) - - def store(self, key, value): - self.client.set(key, (time.time(), value), time=self.timeout) - - def get(self, key, timeout=None): - obj = self.client.get(key) - if obj is None: - return None - created_time, value = obj - - # check if value is expired - if timeout is None: - timeout = self.timeout - if timeout > 0 and (time.time() - created_time) >= timeout: - # expired! delete from cache - self.client.delete(key) - return None - - return value - - def count(self): - count = 0 - for sid, stats in self.client.get_stats(): - count += int(stats.get('curr_items', 0)) - return count - - def cleanup(self): - # not implemented for this cache since server handles it - return - - def flush(self): - self.client.flush_all() -