Memcached Install - windows and linux

 

Outline

Install/Command

Linux

Billing Team Manual
memcached FAQ

install

install libevent
libevent Download
libevent-1.4.12.tar.gz 2009-07-24
$ tar -zxvf libevent-1.x.x.tar.gz
$ ./configure --prefix=/usr/
$ make
$ make test
$ make install

install memcached
memcached Download
memcached-1.4.0.tar.gz - July 9th, 2009
$ tar -zxvf memcached-1.x.x.tar.gz
$ ./configure --prefix=/usr/local/memcached --with-libevent=/usr/ --enable-threads (you probably want threads)
$ make
$ make test
$ sudo make install

Commands

Start/Stop
text protocol

//start
cd /usr/local/memcached/bin
./memcached -d -m 100 -u root -p 11211 -c 256 -P /tmp/memcached.pid
        -m memory allocated for memcached server, unit is MB
        -u the user run memcached.
        -l listen host ip address.
        -p listen port number.
        -c concurrent thread number.
        -P the file saving memcached pid.

//monitor
telnet 172.16.100.117 11211

//shutdown
kill `cat /tmp/memcached.pid`

Storage
set key001 0 0 5
hello
$ STORED
get key001
$ VALUE key001 0 5
$ hello
$ END
delete key001
$ DELETED
get key001
$ END
set key001 0 0 5
hello
$ STORED
flush_all
$ OK
get key001
$ END

  • set <key> <flags> <exptime> <bytes>
  • flush_all : Its effect is to invalidate all existing items immediately (by default) or after the expiration specified.

Windows

memcached-win32

  • Download : version: 1.2.1 - Dec 23, 2006
  • unzip : Unzip the binaries in your desired directory (eg. c:/memcached)
  • setup : c:/memcached/memcached.exe -d install
  • start : c:/memcached/memcached.exe -d start

Client Usage/API

clients

Java - spymemcached

spymemcached
spymemcached javadoc

//connect
MemcachedClient c=new MemcachedClient(
    new InetSocketAddress("hostname", portNum));

// Store a value (async) for one hour
c.set("someKey", 3600, someObject);
// Retrieve a value (synchronously).
Object myObject=c.get("someKey");

// Try to get a value, for up to 5 seconds, and cancel if it doesn't return
Object myObj=null;
Future<Object> f=c.asyncGet("someKey");
try {
    myObj=f.get(5, TimeUnit.SECONDS);
} catch(TimeoutException e) {
    // Since we don't need this, go ahead and cancel the operation.  This
    // is not strictly necessary, but it'll save some work on the server.
    f.cancel(false);
    // Do other timeout related stuff
}

Resources

Inside into memcached, Chinese

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

FireCoder

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值