Install memcached in Mac OS and using it in Perl

memcached is quite powerful but easy to use caching system. I would suggest you to read this wonderful story to make you understand how it works.

To install memcached in Mac os we going to use brew. You can follow to install brew.

brew update
brew install memcached

Then add memcached to launchctl

launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist

You can run as daemon also

memcached -l -p 11211 -d

There two Perl library I found Cache::Memcached::Fast and Cache::Memcached. While using Cache::Memcached I found this error “Storable binary image v48.98 more recent than I am (v2.8)”. Which is happening in line 417. While searching for solution, I found its much harder to fix. So its better to use Cache::Memcached::Fast. Its quite easy to use.

my $memd = new Cache::Memcached::Fast{servers => [$self->memd_server], compress_threshold => 100_000};
my $sub_tree_path = 'cat/car', my $attr = [1,2,3];
$memd->set($sub_tree_path, $attr);
my $memd_attr = $memd->get($sub_tree_path);

About Zakir Hyder

This entry was written by .

26. November 2013 by Zakir Hyder
Categories: Caching, Perl | Tags: , , , , | Comments