Commit 28942ca8 authored by Josh Roesslein's avatar Josh Roesslein
Browse files

Moved memcache implementation to extensions repository.

parent 9a35ff25
......@@ -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]
=====================
......
......@@ -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 <http://code.google.com/p/oauth>
**Bundled with this library
python-memcached <http://www.tummy.com/Community/software/python-memcached/>
**Bundled with this library
......@@ -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__':
......
......@@ -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
......
......@@ -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()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment