Subversion Repositories SmartDukaan

Rev

Blame | Last modification | View Log | RSS feed

package in.shop2020.dtrapi.services;

import com.whalin.MemCached.MemCachedClient;
import com.whalin.MemCached.SockIOPool;


public class MemCache{
    
    //Need to read these from config service.
    private String[] servers = {"localhost:11211"};
    private static MemCache memCache;
    private static SockIOPool pool = SockIOPool.getInstance("SERVER_POOL");
    private static MemCachedClient memcachedClient;
    
    static{
        synchronized(MemCache.class){
            
            memCache = new MemCache();
            memCache.initialize();
            memcachedClient = new MemCachedClient("SERVER_POOL");
        }
    }
    
    private void initialize(){
        pool.setServers(servers);
        pool.initialize();
        System.out.println("Initializing MemCache pool");
    }
    
    public MemCachedClient getClient(){
        return memcachedClient;
    }
    
    
}