initial commit
This commit is contained in:
@@ -0,0 +1,255 @@
|
||||
Thu, 02 Apr 2009 13:37:49 -0600 Sean Reifschneider <jafo@tummy.com>
|
||||
|
||||
* Version 1.44
|
||||
|
||||
* Allowing spaces in the key. (Patch provided by xmm on Launchpad)
|
||||
|
||||
* Detecting when the pickler needs a positional argument. (Patch
|
||||
provided by Brad Clements on Launchpad)
|
||||
|
||||
* Moving length check after the compression. (Patch provided by user
|
||||
Tom on Launchpad)
|
||||
|
||||
* Fixing arguments passed to the _Error if invalid read length.
|
||||
|
||||
* Fixing the representation of domain sockets. (Patch provided by user
|
||||
MTB on Launchpad)
|
||||
|
||||
* Changing a typo of dead_until. (Patch provided by Shane R. Spencer)
|
||||
|
||||
* Providing better error messages (patch provided by Johan Euphrosine).
|
||||
|
||||
* Adding get_slabs() function to get stats. (Patch provided
|
||||
by Nick Verbeck)
|
||||
|
||||
Sun, 01 Jun 2008 15:05:11 -0600 Sean Reifschneider <jafo@tummy.com>
|
||||
|
||||
* Version 1.43
|
||||
|
||||
* eliott reported a bug in the 1.42 related to the socket timeout code
|
||||
causing a traceback due to the timeout value not being set.
|
||||
|
||||
Sat, 31 May 2008 02:09:17 -0600 Sean Reifschneider <jafo@tummy.com>
|
||||
|
||||
* Version 1.42
|
||||
|
||||
* Paul Hummer set up a Launchpad project which I'm going to start using
|
||||
to track patches and allow users to set up their own bzr branches and
|
||||
manage marging in the upstream patches with their own.
|
||||
|
||||
https://launchpad.net/python-memcached
|
||||
|
||||
* Patch from Jehiah Czebotar which does: Changing the calls to
|
||||
mark_dead() to make them dereference tuples, reducing timeout on
|
||||
sockets to 3 seconds, settable via setting Host._SOCKET_TIMEOUT.
|
||||
|
||||
* Patches from Steve Schwarz for set_multi() to return the full set of
|
||||
keys if all servers are down. Previously would not report any keys.
|
||||
|
||||
* Fix from Steve Schwarz delete_multi() argument "seconds" not being
|
||||
correctly handled. Changed it to "time" to match all other calls.
|
||||
|
||||
* Patch from Peter Wilkinson to support using unix domain sockets.
|
||||
He reports that tests succeed with with memcached daemons running,
|
||||
the normal and a domain socket started via
|
||||
"memcached -s memcached.socket". I massaged it quite a bit.
|
||||
|
||||
To use domain sockets, use a connect string of "unix:/path/to/socket"
|
||||
Note however that if you are using a host name of "unix", it will now
|
||||
detect "unix:11211" as being a domain socket with the name "11211".
|
||||
In this case, please use "inet:unix:11211".
|
||||
|
||||
Because of this, it is now preferred to use a connect string prefix
|
||||
of "inet:" or "unix:".
|
||||
|
||||
Tue, 29 Apr 2008 21:03:53 -0600 Sean Reifschneider <jafo@tummy.com>
|
||||
|
||||
* Version 1.41
|
||||
|
||||
* Patch from Jehiah Czebotar to catch an additional server disconnect
|
||||
situation.
|
||||
|
||||
* Patch from Andrey Petrov to add the "append" and "replace" commands.
|
||||
|
||||
Tue, 18 Sep 2007 20:52:09 -0600 Sean Reifschneider <jafo@tummy.com>
|
||||
|
||||
* Version 1.40
|
||||
|
||||
* Updated setup.py file that uses distutils provided by Kai Lautaportti.
|
||||
|
||||
* Prevent keys from containing ASCII character 127 as well, patch provided
|
||||
by Philip Neustrom.
|
||||
|
||||
* Added ability to overload the persistent_load/id, patch provided by
|
||||
Steve Schwarz.
|
||||
|
||||
* Fixed ability to pass (server_hash,key) in place of key in Client.set()
|
||||
Reported by Alexander Klyuev.
|
||||
|
||||
Tue, 14 Aug 2007 14:43:27 -0600 Sean Reifschneider <jafo@tummy.com>
|
||||
|
||||
* Version 1.39
|
||||
|
||||
* Michael Krause reports the previous version doesn't work for
|
||||
_val_to_store_info() calls because it's defined as a staticmethod.
|
||||
Removing staticmethod decorator. Also confirmed by Kai Lautaportti,
|
||||
with suggested fix of removing staticmethod.
|
||||
|
||||
Fri, 10 Aug 2007 17:50:13 -0600 Sean Reifschneider <jafo@tummy.com>
|
||||
|
||||
* Version 1.38
|
||||
|
||||
* Matt McClanahan submitted a patch that allow add() to have a
|
||||
min_compress_len argument.
|
||||
|
||||
* Steve Schwarz submitted a patch allowing user-defined picklers.
|
||||
|
||||
* Michael Krause suggested checking the return value to prevent an
|
||||
exception from being raised in _set() when a value is too large to be
|
||||
stored.
|
||||
|
||||
Fri, 27 Jul 2007 01:55:48 -0600 Sean Reifschneider <jafo@tummy.com>
|
||||
|
||||
* Version 1.37
|
||||
|
||||
* Fixing call from add() to _set() with parameter for min_compress_len.
|
||||
Reported by Jeff Fisher.
|
||||
|
||||
Thu, 07 Jun 2007 04:10:31 -0600 Sean Reifschneider <jafo@tummy.com>
|
||||
|
||||
* Version 1.36
|
||||
|
||||
* Patch by Dave St.Germain to make the Client() class sub-class
|
||||
threadlocal to help with multi-threading issues. Only available in
|
||||
Python 2.4 and above.
|
||||
|
||||
* Patch by James Robinson with:
|
||||
1) new set_multi method.
|
||||
2) factored out determining the flags, length, and value to store
|
||||
from set() into method _val_to_store_info() for use by both set()
|
||||
and set_multi().
|
||||
3) send_cmds() method on host which doesn't apply the trailing '\r\n'
|
||||
for use by set_multi.
|
||||
4) check_key() extended a bit to allow for testing the prefix passed
|
||||
to set_multi just once, not once per each key.
|
||||
5) Patch also enables support for auto compression in set, set_multi,
|
||||
and replace.
|
||||
|
||||
* Suggestion by Helge Tesdal, fixes in check_key for non-string keys.
|
||||
|
||||
* NOTE: On a farm of clients with multiple servers, all clients will
|
||||
need to be upgraded to this version. The next patch changes the
|
||||
server hash.
|
||||
|
||||
* Philip Neustrom supplied a patch to change the server hash function to
|
||||
binascii.crc32. The original "hash()" call is not cross-platform, so
|
||||
big and little endian systems accessing the same memcache may end up
|
||||
hitting different servers. Restore the old functionality by calling:
|
||||
"memcached.serverHashFunction = hash" after importing memcache.
|
||||
|
||||
* Philip Neustrom points out that passing Unicode keys or values causes
|
||||
problems because len(key) or len(value) is not equal to the number of
|
||||
bytes that are required to store the key/value. Philip provides a
|
||||
patch which raises an exception in this case. Raises
|
||||
memcache.Client.MemcachedStringEncodingError exception in this case.
|
||||
|
||||
* NOTE: If you recompiled memcached to increase the default 1MB max
|
||||
value size, you will need to call "memcached.MAX_SERVER_VALUE_LENGTH = N"
|
||||
or memcached will not store values larger than the default 1MB.
|
||||
|
||||
* Philip Neustrom includes another patch which checks that the key
|
||||
doesn't exceed the memcache server's max size. If it does, the item
|
||||
is silently not stored.
|
||||
|
||||
* Philip Neustrom added a bunch of sanity checks.
|
||||
|
||||
* Jehiah Czebotar provided a patch to make the add() and replace()
|
||||
functions return 0 when the add or replace fails, similar to how set()
|
||||
works.
|
||||
|
||||
Sat, 16 Sep 2006 18:31:46 -0600 Sean Reifschneider <jafo@tummy.com>
|
||||
|
||||
* Version 1.34
|
||||
|
||||
* In get_multi, if the recv loop reads 0 bytes, raising an EOFError.
|
||||
Identified by Jim Baker.
|
||||
|
||||
Tue, 05 Sep 2006 14:06:50 -0600 Sean Reifschneider <jafo@tummy.com>
|
||||
|
||||
* Version 1.33
|
||||
|
||||
* Including patch from Yoshinori K. Okuji to read in larger chunks for
|
||||
readline() calls. This should dramatically improve performance under
|
||||
some circumstances.
|
||||
|
||||
Sun, 03 Sep 2006 14:02:03 -0600 Sean Reifschneider <jafo@tummy.com>
|
||||
|
||||
* Version 1.32
|
||||
|
||||
* Including patch from Philip Neustrom which checks keys sent to the
|
||||
server for length and bad characters.
|
||||
|
||||
Sat, 20 May 2006 14:51:28 -0600 Sean Reifschneider <jafo@tummy.com>
|
||||
|
||||
* Version 1.31
|
||||
|
||||
* Rolled version 1.30 since the Danga folks are now listing this
|
||||
version as the official version. Removing the "tummy" from the version
|
||||
number, and incrementing so that it's clear it's more recent than "1.2".
|
||||
|
||||
* Patch applied from Simon Forman for handling of weighted hosts.
|
||||
|
||||
* Added a little more meat to the README.
|
||||
|
||||
Sat, 28 Jan 2006 15:59:50 -0700 Sean Reifschneider <jafo@tummy.com>
|
||||
|
||||
* cludwin at socallocal suggested that the write-combining with
|
||||
sendall() may not be beneficial. After testing on both SMP and non-SMP
|
||||
machines, I can't see a significant benefit to not doing the
|
||||
write-combining, even on large strings. The benefits of write-combining
|
||||
on smaller strings seems to be significant on UP machines in tight loops.
|
||||
Even on strings that are larger than 2MB, there seems to be no benefit to
|
||||
splitting out the writes.
|
||||
|
||||
Sun, 18 Sep 2005 18:56:31 -0600 Sean Reifschneider <jafo@tummy.com>
|
||||
|
||||
* Changing a printf to debuglog and catching a pickle exception, patch
|
||||
submitted by Justin Azoff.
|
||||
|
||||
Thu, 14 Jul 2005 11:17:30 -0700 Sean Reifschneider <jafo@tummy.com>
|
||||
|
||||
* Alex Stapleton found that the sendall call was slow for writing data
|
||||
larger than several kilobytes. I had him test a change to his patch,
|
||||
which worked as well, but was simpler. The code now does two sendall
|
||||
calls, one for the data and one for the line termination, if the data is
|
||||
larger than 100 bytes.
|
||||
|
||||
Thu, 7 Apr 2005 14:45:44 -0700 Sean Reifschneider <jafo@tummy.com>
|
||||
|
||||
* Incorporating some fixes to get_multi() from Bo Yang
|
||||
|
||||
Mon, 13 Dec 2004 02:35:17 -0700 Sean Reifschneider <jafo@tummy.com>
|
||||
|
||||
* Simplifying the readline() function and speeding it up ~25%.
|
||||
* Fixing a bug in readline() if the server drops, mark_dead() was not
|
||||
being properly called.
|
||||
|
||||
Sun, 12 Dec 2004 18:56:33 -0700 Sean Reifschneider <jafo@tummy.com>
|
||||
|
||||
* Adding "stats()" and "flush_all()" methods.
|
||||
|
||||
Thu, 10 Aug 2003 12:17:50 -0700 Evan Martin <martine@danga.com>
|
||||
|
||||
* Slightly more verbose self-test output.
|
||||
* Fix mark_dead() to use proper classname.
|
||||
* Make pooltest.py run from the test directory.
|
||||
|
||||
Thu, 07 Aug 2003 16:32:32 -0700 Evan Martin <martine@danga.com>
|
||||
|
||||
* Add incr, decr, and delete.
|
||||
* Better Python (based on comments from Uriah Welcome).
|
||||
* Docs, using epydoc.
|
||||
|
||||
Thu, 07 Aug 2003 14:20:27 -0700 Evan Martin <martine@danga.com>
|
||||
|
||||
* Initial prerelease.
|
||||
@@ -0,0 +1,10 @@
|
||||
Metadata-Version: 1.0
|
||||
Name: python-memcached
|
||||
Version: 1.44
|
||||
Summary: A Python memcached client library.
|
||||
Home-page: http://www.danga.com/memcached/
|
||||
Author: Evan Martin
|
||||
Author-email: martine@danga.com
|
||||
License: Python
|
||||
Description: A Python memcached client library.
|
||||
Platform: UNKNOWN
|
||||
@@ -0,0 +1,7 @@
|
||||
This package was originally written by Evan Martin of Danga.
|
||||
Sean Reifschneider of tummy.com, ltd. has taken over maintenance of it.
|
||||
|
||||
This software is a 100% Python interface to the memcached memory cache
|
||||
daemon. It is the client side software which allows storing values in one
|
||||
or more, possibly remote, memcached servers. Search google for memcached
|
||||
for more information.
|
||||
@@ -0,0 +1,89 @@
|
||||
from gluon.contrib.memcache.memcache import Client
|
||||
from gluon.cache import CacheAbstract
|
||||
import time
|
||||
|
||||
"""
|
||||
examle of usage:
|
||||
|
||||
cache.memcache = MemcacheClient(request,[127.0.0.1:11211],debug=true)
|
||||
"""
|
||||
|
||||
import cPickle as pickle
|
||||
import thread
|
||||
|
||||
locker = thread.allocate_lock()
|
||||
|
||||
def MemcacheClient(*a, **b):
|
||||
locker.acquire()
|
||||
try:
|
||||
if not hasattr(MemcacheClient, '__mc_instance'):
|
||||
MemcacheClient.__mc_instance = _MemcacheClient(*a, **b)
|
||||
finally:
|
||||
locker.release()
|
||||
return MemcacheClient.__mc_instance
|
||||
|
||||
class _MemcacheClient(Client):
|
||||
|
||||
meta_storage = {}
|
||||
|
||||
def __init__(self, request, servers, debug=0, pickleProtocol=0,
|
||||
pickler=pickle.Pickler, unpickler=pickle.Unpickler,
|
||||
pload=None, pid=None):
|
||||
self.request=request
|
||||
if request:
|
||||
app = request.application
|
||||
else:
|
||||
app = ''
|
||||
Client.__init__(self, servers, debug, pickleProtocol,
|
||||
pickler, unpickler, pload, pid)
|
||||
if not app in self.meta_storage:
|
||||
self.storage = self.meta_storage[app] = {
|
||||
CacheAbstract.cache_stats_name: {
|
||||
'hit_total': 0,
|
||||
'misses': 0,
|
||||
}}
|
||||
else:
|
||||
self.storage = self.meta_storage[app]
|
||||
|
||||
|
||||
def __call__(self, key, f, time_expire=300):
|
||||
if time_expire == None:
|
||||
time_expire = 10**10
|
||||
# this must be commented because get and set are redefined
|
||||
# key = self.__keyFormat__(key)
|
||||
value = None
|
||||
obj = self.get(key)
|
||||
if obj:
|
||||
value = obj
|
||||
elif f is None:
|
||||
if obj: self.delete(key)
|
||||
else:
|
||||
value = f()
|
||||
self.set(key, value, time_expire)
|
||||
return value
|
||||
|
||||
def increment(self, key, value=1, time_expire=300):
|
||||
newKey = self.__keyFormat__(key)
|
||||
obj = Client.get(self, newKey)
|
||||
if obj:
|
||||
return Client.incr(self, newKey, value)
|
||||
else:
|
||||
Client.set(self, newKey, value, time_expire)
|
||||
return value
|
||||
|
||||
def set(self, key, value, time_expire=300):
|
||||
newKey = self.__keyFormat__(key)
|
||||
return Client.set(self, newKey, value, time_expire)
|
||||
|
||||
def get(self, key):
|
||||
newKey = self.__keyFormat__(key)
|
||||
return Client.get(self, newKey)
|
||||
|
||||
def delete(self, key):
|
||||
newKey = self.__keyFormat__(key)
|
||||
return Client.delete(self, newKey)
|
||||
|
||||
def __keyFormat__(self, key):
|
||||
return '%s/%s' % (self.request.application, key.replace(' ', '_'))
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user