Database Reference
In-Depth Information
Setting up memcache
The following are the steps that need to be executed and will be required for the installation
of memcache:
wget http://memcached.org/latest
tar -zxvfmemcached-1.x.x.tar.gz
cdmemcached-1.x.x
./configure && make && make test &&sudo make install
The following is the code snippet to connect to the memcache client and functions. It re-
trieves the data from the cache:
public class MemCacheClient {
private static MemcachedClient client = null;
private static final Logger logger =
LogUtils.getLogger(MemCacheClient.class);
/**
* Constructor that accepts the cache properties as
parameter and initialises the client object accordingly.
* @param properties
* @throws Exception
*/
publicMemCacheClient(Properties properties) throws
Exception {
super();
try {
if (null == client) {
client = new MemcachedClient(new InetSocketAddress(
102.23.34.22,
5454)));
}
} catch (IOException e) {
if (null != client)
shutdown();
throw new Exception("Error while initiating
MemCacheClient", e);
Search WWH ::




Custom Search