[announce] php: mcache extensions 1.1.0

John McCaskey johnm at klir.com
Thu Jan 27 14:49:15 PST 2005

Hey everyone,

I've just released 1.1.0 of my php mcache extension.  Please see the
site at http://www.klir.com/~johnm/php-mcache/

The changes in brief are:

1) Disallowed setting of flags field from the set, add, or replace
methods.  This was done because I use the flags field internally to keep
track of types and serialization of complex data.  Also, even in 1.0
there was no way to actually get the flags field back.  I suggest
storing any extra data you need by doing something like $mc->set('key',
Array('val'=>value, 'flags'=>myflags));  This change breaks the api for
existing programs, so please upgrade cautiously :)

2) Added support for persistent memcache objects.  This is especially
useful if you have a scenario where a server might go down and the
connection is timing out. Previously each page load would wait on the
connection timeout which could be rather slow.  Now, the timeout will be
remembered between pages.  You can set an expiration time for the
persistent object to whatever you like so that you could make it retry
on say every 5 minutes so that if the server comes back up it goes back
into active use.  See example code below:

$mc = pmemcache('my_unique_mc_object', 300); // keep it persistent for 5 minutes
 * After creating a persistent object, you may or may not need to add servers.  You only
 * want to add them if the object is newly created, and has not yet been initialized, check
 * as follows.
 if(!$mc->is_initialized()) {
	$mc->add_server('localhost', '11211');
	$mc->add_server('localhost', '11212');

	 * Now that you are done initializing mark the object as initialized so that on
	 * the next page load you don't repeat the server adds.

 * All your regular $mc->set(), $mc->get, whatever goes here.

3) Fixed a bug where if a long, double, or boolean value was stored in
the cache I would return the string representation of the value, rather
than the originally stored type.  Due to php's dynamic typing this
wouldn't typically cause a problem, but the bug is now fixed and you
should always get back exactly what you store in the same type.

As always, please send bug reports, comments, and feature requests!

John A. McCaskey
Software Development Engineer
Klir Technologies, Inc.
johnm at klir.com

More information about the memcached mailing list