]> git.evergreen-ils.org Git - OpenSRF.git/blob - src/java/org/opensrf/util/Cache.java
added a memcache client and test
[OpenSRF.git] / src / java / org / opensrf / util / Cache.java
1 package org.opensrf.util;
2 import com.danga.MemCached.*;
3 import java.util.List;
4
5 /**
6  * Memcache client
7  */
8 public class Cache extends MemCachedClient {
9
10     public Cache() {
11         super();
12         setCompressThreshold(4096); /* ?? */
13     }
14
15     /**
16      * Initializes the cache client
17      * @param serverList Array of server:port strings specifying the
18      * set of memcache servers this client will talk to
19      */
20     public static void initCache(String[] serverList) {
21         SockIOPool pool = SockIOPool.getInstance();
22         pool.setServers(serverList);
23         pool.initialize();      
24         com.danga.MemCached.Logger logger = 
25             com.danga.MemCached.Logger.getLogger(MemCachedClient.class.getName());
26         logger.setLevel(logger.LEVEL_ERROR);
27     }
28
29     /**
30      * Initializes the cache client
31      * @param serverList List of server:port strings specifying the
32      * set of memcache servers this client will talk to
33      */
34     public static void initCache(List<String> serverList) {
35         initCache(serverList.toArray(new String[]{}));
36     }
37 }
38