Sharing cache objects between PERL and PHP

KevinImNotSpacey kevin.amerson at gmail.com
Fri Jun 22 22:10:00 UTC 2007


This is a client thing, I was able to put and fetch from Python and .NET for
instance, to the same memcached instance.

On 6/22/07, The Newb <ne_wb at hotmail.com> wrote:
>
>
> Hello,
>
> I'm using Cache::Memcached on the PERL side and the PECL libraries for PHP
> in PHP 4.x. The data objects are session data that I would like to share
> between both languages, however when I telnet straight into the memcache
> daemon and do gets on the keys, it appears that the data objects are stored
> in completely different formats. Do I have a setting wrong, is this a
> permanent limitation, wrong library or not enough RTFM? It works fine in
> either language. I'm just missing the cross-compatability. If someone could
> point me toward correct answer, it would be much appreciated.
>
> Thanks
>
> ### PERL EXAMPLE
>
> use Cache::Memcached;
> require Digest::MD5;
> my $memd = new Cache::Memcached {
>     'servers' => [ "127.0.0.1:11211"],
>  debug => 1
>   };
> $memd->enable_compress(0);
> $sess_id = "d116f2af6b07deaac588c8c34cca919b";
> $session->{'first'} = "john";
> $session->{'last'} = "smith";
> $session->{'session_id'} = $sess_id;
>
> $memd->set("$sess_id", $session,60);
>
>
> ### MEMCACHE RESULT
>
> telnet 127.0.0.1 11211
> Trying 127.0.0.1...
> Connected to localhost.localdomain (127.0.0.1).
> Escape character is '^]'.
> get d116f2af6b07deaac588c8c34cca919b
> VALUE d116f2af6b07deaac588c8c34cca919b 1 85
>  d116f2af6b07deaac588c8c34cca919b
> session_id
> johnfirst
> smithlast
> END
>
> ### PHP EXAMPLE
>
> $memcache = new Memcache;
> $memcache->connect('127.0.0.1', 11211) or die ("Could not connect");
> $sess_id = "d116f2af6b07deaac588c8c34cca919b";
> $session->first = "john";
> $session->last  = "smith";
> $session->session_id  = "$sess_id";
> $memcache->set($sess_id,$session,false,900);
>
> ### MEMCACHE RESULT
>
> get d116f2af6b07deaac588c8c34cca919b
> VALUE d116f2af6b07deaac588c8c34cca919b 1 123
>
> O:8:"stdClass":3:{s:5:"first";s:4:"john";s:4:"last";s:5:"smith";s:10:"session_id";s:32:"d116f2af6b07deaac588c8c34cca919b";}
> END
>
> ------------------------------
> Change is good. See what's different about Windows Live Hotmail. Check it
> out!<http://www.windowslive-hotmail.com/learnmore/default.html?locale=en-us&ocid=RMT_TAGLM_HMWL_reten_changegood_0607>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.danga.com/pipermail/memcached/attachments/20070622/68438c67/attachment.htm


More information about the memcached mailing list