Need different types of caches

Greg Whalin gwhalin at meetup.com
Fri Aug 11 13:24:01 UTC 2006


I see you setting up multiple pools, but I do not see you setting up any 
  Memcache client objects in your code?

Also, in order to support multiple pools you need to use a name for 
them.  In your example, pool and pool2 are merely references to the same 
instance of the pool ...

SockIOPool pool1 = SockIOPool.getInstance( "pool1" );
SockIOPool pool2 = SockIOPool.getInstance( "pool2" );
...
MemCachedClient mcc1 = new MemCachedClient();
MemCachedClient mcc2 = new MemCachedClient();
mcc1.setPoolName( "pool1" );
mcc2.setPoolName( "pool2" );


Also, if all you want is separate namespaces, you can accomplish that w/ 
naming conventions for your keys.  No need to dedicate a different 
server for different types of cache.  The main reason for supporting 
multiple clusters of cache servers is typically based on the need to 
cache objects that are very small and objects that are very large.

Abhishek wrote:
> Hi,
> I was trying my hand on memcache - java version, experimenting a little 
> bit. What i cannot understand is how do I keep different types of caches 
> on memcache. I tried creating two separate SocketIOPool connections with 
> same server address but different ports. See below :-
> public MemCacheImpl() {
>         String[] serverlist = {"172.16.2.82:11211"};
>         String[] serverlist2 = {"172.16.2.82:11212"};
> 
>         // initialize the pool for memcache servers
>         SockIOPool pool = SockIOPool.getInstance();
>         SockIOPool pool2 = SockIOPool.getInstance();
>         pool.setServers(serverlist);
>         pool2.setServers(serverlist2);
> 
> 
>         pool.setInitConn(5);
>         pool.setMinConn(5);
>         pool.setMaxConn(50);
>         pool.setMaintSleep(30);
> 
>         pool.setNagle(false);
>         pool.initialize();
>         //for pool2
>         pool2.setInitConn(5);
>         pool2.setMinConn(5);
>         pool2.setMaxConn(50);
>         pool2.setMaintSleep(30);
> 
>         pool2.setNagle(false);
>         pool2.initialize();
> 
>     }
> It gave an exception as ++++++ trying to initialize an already 
> initialized pool.
> 
> By different types of caches I mean I need to store PersonCache, 
> ProjectCache   in memcache. Currently I have these caches as 
> implementation of Maps. But I want that a key  of particular map(cache) 
> goes into one memcache server. How can I do that?
> ie.
> PersonCache = Map
> Key = personID
> value = PersonValueObject
> 
> ProjectCache = Map
> Key  = projectID
> Value = ProjectValueObject
> 
> Now, If I have two memcache servers running on different ports as 
> mentioned above, how do I designate an Element(key-value) of PersonCache 
> to go to only server1 and Element of ProjectCache to go to server2 ??
> 
> Can u pls tell me how can I create different caches on memcache? Also 
> how can I create different configuration of SocketIOPool (s), so that 
> they act as 'different caches' ??
> 
> Regards,
> Abbey.
> 
> 
> ------------------------------------------------------------------------
> Yahoo! Messenger with Voice. Make PC-to-Phone Calls 
> <http://us.rd.yahoo.com/mail_us/taglines/postman1/*http://us.rd.yahoo.com/evt=39663/*http://voice.yahoo.com> 
> to the US (and 30+ countries) for 2¢/min or less.



More information about the memcached mailing list