FreeBSD 14
Sponsored Link

Memcached : Use on Perl2024/09/16

 

This is the example to use Memcached on Perl.

[1] This is the example to use Memcached on Perl.
root@dlp:~ #
pkg install -y p5-Cache-Memcached
[2] Install Perl Memcached Client Module.
freebsd@dlp:~ $
vi use_memcache.pl
use strict;
use Cache::Memcached;

my $memcached = Cache::Memcached->new({
    servers => ["127.0.0.1:11211"]
});

# set and get a Key
$memcached->set('key01', 'value01');
print "key01.value : " . $memcached->get('key01') . "\n";

# append and get a Key
$memcached->append('key01', ',value02');
print "key01.value : " . $memcached->get('key01') . "\n";

$memcached->set('key02', 1);
print "key02.value : " . $memcached->get('key02') . "\n";

# increment
$memcached->incr('key02', 100);
print "key02.value : " . $memcached->get('key02') . "\n";

# decrement
$memcached->decr('key02', 51);
print "key02.value : " . $memcached->get('key02') . "\n";

# run

freebsd@dlp:~ $
perl use_memcache.pl

key01.value : value01
key01.value : value01,value02
key02.value : 1
key02.value : 101
key02.value : 50
Matched Content