----- Original Message -----
Sent: Tuesday, January 18, 2005 10:33
PM
Subject: [announce] php: mcache extension
1.0
See attached source code.
Unfortunately
libmemcache uses the "%hu" and "%zu" format specifiers which at least on my
box (linux 2.6.10, php 4.3.10) break inside of php extensions for some reason,
so to make this actually compile you must patch your libmemcache 1.2.0 source
to just use "%u", use the attached patch file for this.
Then to install
the extension follow the below steps after extracting:
$ phpize
$
./configure --with-mcache=/path/to/patched/libmemcache/source/
$ make
$
make install
then add mcache.so to your php.ini.
You can
look at the following examples for usage, or view the mcache.c file which has
PECL standard comments about the functions.
<?php
$mc =
memcache();
$mc->add_server('127.0.0.1',
'11211');
$mc->add_server('127.0.0.1',
'11212');
$mc->set('key1', 'value_one');
$mc->add('key2',
'value_two');
$mc->replace('key2', 'two_value');
// This returns
FALSE on miss
$val = $mc->get('key1');
// This returns an
associative array with
// an entry for each key found, a miss will simply
result
// in no entry in the array for that key.
$val =
$mc->get(Array('key1',
'key2'));
$mc->delete('key1');
?>
Thats the basics,
the remaining supported commands are: stats, incr, decr, flush_all, which
should be pretty easy to figure out.
Please feel free to send feedback
and/or bug fixes :) This is my first php extension although I'm
experienced in both php and c, writing primarily c code lately. So I
wouldn't be shocked to find that I haven't done everything
perfectly.
Oh, and finally a note on licensing, I've left in the php
header which claims the code is subject to the php license. I'm not sure
how the php license works and if I can change it freely to whatever license I
want or what. I basically don't care what you do with this, feel free to
use it and make changes, redistribute, use in commercial projects,
whatever. If you are concerned about the license feel free to contact
me.
--
John A. McCaskey
Software Development Engineer
Klir
Technologies,
Inc.
johnm@xxxxxxxx
206.902.2027