GithubHelp home page GithubHelp logo

mc's Introduction

NAME

MC - Async Memcached client using Mojo::IOLoop for event loop

SYNOPSIS

use MC;

# Blocking API

my $mc = MC->new('localhost', 11211);
my $flags = 13;
$mc->set('key', $flags, 'value');
my $value = $mc->get('key')->{value}; # value
$mc->delete('key');
$value = $mc->get('key'); # undef
$mc->set('key1', 0, 'value1');
$mc->set('key2', 0, 'value2');
my $values = $mc->get([qw/key1 key2/]);
print $values->{key1}{value}; # value1
print $values->{key2}{flags}; # 0

# Non-blocking API

use Mojo::IOLoop;
$mc->set(('akey', 1, 'avalue') => sub {
  my ($mc, $err, $response) = @_;
  die "Error: $err" if $err;
  $mc->get(akey => sub {
    my ($mc, $err, $response) = @_;
      die "Error: $err" if $err;
      print $response->{value}; # avalue
      Mojo::IOLoop->stop;
  });
});

Mojo::IOLoop->start;

METHODS

set

$mc->set($key, $flags, $value);
$mc->set($key, $flags, $value, {exptime => 10});

Store $value and $flags associated with $key in Memcached.

$mc->set($key, $flags, $value, sub {
  my ($mc, $err, $response) = @_;
  ...
});

You can append callback to set for perform methond non-blocking.

get

$mc->get($key); # {value => '...', flags => '...'}
$mc->get([$key1, $key2, $key3]); # {$key1 => {...}, $key2 => {...}}

Get one or more flags and values from Memcached by key(s).

$mc->get([$key1, $key2] => sub {
  my ($mc, $err, $response) = @_;
  ...
});

You can append callback to get for perform methond non-blocking.

delete

$mc->delete($key);

Delete flags and value associated with $key from Memcached.

$mc->delete($key => sub {
  my ($mc, $err, $response) = @_;
  ...
});

You can append callback to delete for perform methond non-blocking.

mc's People

Contributors

avkhozov avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.