Andrea Guzzo > Shardcache-Client-Fast-0.20 > Shardcache::Client::Fast

Download:
Shardcache-Client-Fast-0.20.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.20   Source  

NAME ^

Shardcache::Client::Fast - Perl extension for the client part of libshardcache

SYNOPSIS ^

  use Shardcache::Client::Fast;
  @hosts = ("peer1:localhost:4444", "peer2:localhost:4445", "peer3:localhost:4446" );
  $secret = "some_secret";
  $c = Shardcache::Client::Fast->new(\@hosts, $secret, $log_level);

  # Set a new value for key "key"
  $rc = $c->set("key", "value");
  if ($rc != 0) {
    die "Error setting key 'key' : " . $c->errstr;
  }

  # Read the value back
  $v = $c->get("key");
  if (!$v && $c->errno) {
    die "Error getting value for key 'key' : " . $c->errstr;
  }

  # set the key "key2" and make it expire in 60 seconds
  $c->set("key2", "value2", 60);

  # evict "key"
  $c->evict("key");

  # remove "key2" prematurely
  $c->del("key2");

  
  # check if "peer3" is alive
  if ($c->check("peer3") != 0) {
    warn "peer3 is not responding";
  }

  # get the index of keys existing on "peer2"
  $index = $c->index("peer2");

DESCRIPTION ^

Perl bindings to libshardcache-client. This library is a replacement for the pure-perl Shardcache::Client allowing faster access to shardcache nodes by using libshardcache directly instead of reimplementing the protocol and handling connections on the perl side.

EXPORT

None by default.

METHODS ^

REQUIRED PARAMS

@$hosts
    An arrayref of 'name:address:port' strings describing the nodes serving the sharded cache

OPTIONAL PARAMS

$secret
    A secret used to compute the signature used for internal communication.
    If not specified the string 'default' will be used 
$log_level
    The loglevel used by libshardcache internal routines.
    Note that libshardcache uses syslog levels and it initializes
    itself by evaluating the expression : "LOG_INFO + $log_level".
    So anything greater than 0 will enable debug messages (there are up to 5 debug levels);
    negative numbers will progressively inhibit info, notice, warning and error messages.

SEE ALSO ^

AUTHOR ^

xant, <xant@xant.net>

COPYRIGHT AND LICENSE ^

Copyright (C) 2013 by xant

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.12.4 or, at your option, any later version of Perl 5 you may have available.

syntax highlighting: