Memcached : Use on Perl2023/07/19 |
This is the example to use Memcached on Perl.
|
|
[1] | This is the example to use Memcached on Perl. |
root@dlp:~# apt -y install libcache-memcached-perl
|
[2] | Install Perl Memcached Client Module. |
debian@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 debian@dlp:~$ perl use_memcache.pl key01.value : value01 key01.value : value01,value02 key02.value : 1 key02.value : 101 key02.value : 50 |
Sponsored Link |