Cache::Memcached::Fast

Perl client for memcached, in C language
Download

Cache::Memcached::Fast Ranking & Summary

Advertisement

  • Rating:
  • License:
  • Perl Artistic License
  • Price:
  • FREE
  • Publisher Name:
  • Tomash Brechko
  • Publisher web site:
  • http://search.cpan.org/~kroki/

Cache::Memcached::Fast Tags


Cache::Memcached::Fast Description

Perl client for memcached, in C language Cache::Memcahced::Fast is a Perl module for memcached, a memory cache daemon (http://www.danga.com/memcached/). Module core is implemented in C and tries hard to minimize number of system calls and to avoid any key/value copying for speed. As a result, it has very low CPU consumption.API is largely compatible with Cache::Memcached, original pure Perl client, most users of the original module may start using this module by installing it and adding "::Fast" to the old name in their scripts (see "Compatibility with Cache::Memcached" below for full details).SYNOPSIS use Cache::Memcached::Fast; my $memd = new Cache::Memcached::Fast({ servers => , namespace => 'my:', connect_timeout => 0.2, io_timeout => 0.5, close_on_error => 1, compress_threshold => 100_000, compress_ratio => 0.9, compress_methods => , max_failures => 3, failure_timeout => 2, ketama_points => 150, nowait => 1, hash_namespace => 1, serialize_methods => , utf8 => ($^V ge v5.8.1 ? 1 : 0), max_size => 512 * 1024, }); # Get server versions. my $versions = $memd->server_versions; while (my ($server, $version) = each %$versions) { #... } # Store scalars. $memd->add('skey', 'text'); $memd->add_multi(, ); $memd->replace('skey', 'val'); $memd->replace_multi(, ); $memd->set('nkey', 5); $memd->set_multi(, ); # Store arbitrary Perl data structures. my %hash = (a => 1, b => 2); my @list = (1, 2); $memd->set('hash', \%hash); $memd->set_multi(, ); # Add to strings. $memd->prepend('skey', 'This is a '); $memd->prepend_multi(, ); $memd->append('skey', 'ue.'); $memd->append_multi(, ); # Do arithmetic. $memd->incr('nkey', 10); print "OK " if $memd->decr('nkey', 3) == 12; my @counters = qw(c1 c2); $memd->set_multi(map { } @counters, 'c3', 'c4'); $memd->incr_multi(, @counters, ); # Retrieve values. my $val = $memd->get('skey'); print "OK " if $val eq 'This is a value.'; my $href = $memd->get_multi('hash', 'nkey'); print "OK " if $href->{hash}->{b} == 2 and $href->{nkey} == 12; # Do atomic test-and-set operations. my $cas_val = $memd->gets('nkey'); $$cas_val = 0 if $$cas_val == 12; if ($memd->cas('nkey', @$cas_val)) { print "OK, value updated "; } else { print "Update failed, probably another client" . " has updated the value "; } # Delete some data. $memd->delete('skey'); my @keys = qw(k1 k2 k3); $memd->delete_multi(@keys, ); # Wait for all commands that were executed in nowait mode. $memd->nowait_push; # Wipe out all cached data. $memd->flush_all; Requirements: · Perl


Cache::Memcached::Fast Related Software