2.memcached
3.MongoDB
2.memcached The
Memcached daemon is written in c and is a high-performance distributed memory object caching system
2.1 memcached installation
http://s3.amazonaws.com/downloads.northscale.com/memcached -win32-1.4.4-14.zip
http://s3.amazonaws.com/downloads.northscale.com/memcached-win64-1.4.4-14.zip
download and unzip memcached-win32-1.4.4-14. zip to memcached and overwrite the 3 files in memcached-win64-1.4.4-14.zip with the files in memcached.
#Enter the memcached root directory and register as a windows service:
D:\service\memcached>memcached.exe -d install
#Enter the memcached root directory to check whether the installation is successful:
D:\service\memcached>memcached -h
If the parameters are returned, the installation Success #start
service
> net start memcached
or #start
service
D:\service\memcached>memcached.exe -d start
#Test whether the startup is successful
telnet 127.0.0.1 11211 #Other
systems and commands or parameters:
memcached.exe -d stop
memcached.exe -d uninstall
-m Maximum memory usage, in MB. The default is 64MB
-c the maximum number of simultaneous connections, the default is 1024
-p listening port
For example :
> memcached.exe -p 10000 -m 512 -d start
2.2 memcached uses -client
> telnet 127.0.0.1 11211
client connection server The
command format is :
<command name> <key> <flags> <exptime> <bytes>//Note, remember to press Enter here <data block>
<bytes> is the length of your input <data block>, you must enter the same length of characters and return stored , return an error:
CLIENT_ERROR bad data chunk
such as:
#memcached server information
>stats
#Add value
>add key 0 0 2
>12
> stored #Get
value
>get key #Modify
>
set key 0 10 2
>13
>stored
2.3 memcached uses -java
https://github.com/gwhalin/Memcached-Java-Client
to add jar:
<dependency> <groupId>com.whalin</groupId> <artifactId>Memcached-Java-Client</artifactId> <version>3.0.2</version> </dependency>
package com.byron.memcached.client; import com.whalin.MemCached.MemCachedClient; import com.whalin.MemCached.SockIOPool; public class MemCachedTest { public static void main(String[] args) { // SockIOPool initialization String[] servers = { "127.0.0.1:11211" }; SockIOPool pool = SockIOPool.getInstance(); pool.setServers(servers); pool.setFailover(true); pool.setInitConn(10); pool.setMinConn(5); pool.setMaxConn(250); pool.setMaintSleep(30); pool.setNagle(false); pool.setSocketTO(3000); pool.setAliveCheck(true); pool.initialize(); // New client: default from MemCachedClient memCachedClient = new MemCachedClient(); for (int i = 0; i < 10; i++) { // adding data boolean success = memCachedClient.set("" + i, "Hello!"); // retrieve data String result = (String) memCachedClient.get("" + i); System.out.println(String.format("set( %d ): %s", i, success)); System.out.println(String.format("get( %d ): %s", i, result)); } } }
2.4 Memcached uses -hibernate . In
the influence of hibernate, hibernate will come to memcached. Since I have not used hibernate for a long time, I have been using ibatis, so I will no longer build an instance.
Memcached is an object cache server, so it is a good scene to integrate with hibernate. This is also an advantage compared to redis
2.5 Memcached distributed principle
Reference website:
JAVA client API calls memcached in two ways
http://www.cnblogs.com/longshiyVip/p/4889817.html
http://www.cnblogs .com/sunniest/p/4154209.html
Memcached and Memcache installation (64-bit win7)
http://www.cnblogs.com/wujuntian/p/4791220.html
telnet memcached error: "CLIENT_ERROR bad data chunk"
http:// f.dataguru.cn/thread-46013-1-1.html