Subversion Repositories SmartDukaan

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
15029 kshitij.so 1
package in.shop2020.dtrapi.services;
2
 
3
import com.whalin.MemCached.MemCachedClient;
4
import com.whalin.MemCached.SockIOPool;
5
 
6
 
7
public class MemCache{
8
 
9
    //Need to read these from config service.
10
    private String[] servers = {"localhost:11211"};
11
    private static MemCache memCache;
12
    private static SockIOPool pool = SockIOPool.getInstance("SERVER_POOL");
13
    private static MemCachedClient memcachedClient;
14
 
15
    static{
16
        synchronized(MemCache.class){
17
 
18
            memCache = new MemCache();
19
            memCache.initialize();
20
            memcachedClient = new MemCachedClient("SERVER_POOL");
21
        }
22
    }
23
 
24
    private void initialize(){
25
        pool.setServers(servers);
26
        pool.initialize();
27
        System.out.println("Initializing MemCache pool");
28
    }
29
 
30
    public MemCachedClient getClient(){
31
        return memcachedClient;
32
    }
33
 
34
 
35
}