commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chopin hu <>
Subject Re: [JCS]--How to get a list of Keys in a region
Date Mon, 16 Jan 2012 17:06:13 GMT
Not really get it.    here is the function to get a list of keys from a group in a region:

    public void getKeyList() {

            try {
                //Set keyset = cache.getGroupKeys("myGroup1");
                Iterator iterator  = cache.getGroupKeys("myGroup1").iterator();

                while (iterator.hasNext()) { 
                    String detail = ""; 
                    String ckey = (String);  
            } catch(UnsupportedOperationException uoe) { 
            } catch (Exception e) { 
        return keyList;

It compiles, but at run-time, always complains "UnsupportedOperationException" at the line:
 Iterator iterator  = cache.getGroupKeys("myGroup1").iterator(); 

detailed error msg:
        at org.apache.jcs.auxiliary.disk.file.FileDiskCache.getGroupKeys(
        at org.apache.jcs.engine.control.CompositeCache.getGroupKeys(
        at org.apache.jcs.access.GroupCacheAccess.getGroupKeys(
        at gov.nasa.gsfc.giovanni.TestCache.getKeyList( 
        at gov.nasa.gsfc.giovanni.TestCache.main(

What could be wrong?    


--- On Sat, 1/14/12, Thomas Vandahl <> wrote:

From: Thomas Vandahl <>
Subject: Re: [JCS]--How to get a list of Keys in a region
To: "Commons Users List" <>
Date: Saturday, January 14, 2012, 4:43 AM

On 13.01.12 15:59, Chopin hu wrote:
> Vijayakumar,
> Thanks for your response.   The method cache.putInGroup() does not seem to really
work in my case.   I am working a simple commandline utility, which will extract all keys
from a cache region.   No key/value can be known in advance.   Besides, I don't understand
the concept of "groupName" yet in a cache region.   It looks I don't have a group name
> But is this some method that I can trick it so that it can return all cache keys from
a region?
> --- On Fri, 1/13/12, NM, Vijayakumar <> wrote:
> From: NM, Vijayakumar <>
> Subject: RE: [JCS]--How to get a list of Keys in a region
> To: "Commons Users List" <>
> Date: Friday, January 13, 2012, 12:41 AM
> Hi,
> This may be of some help.
> JCS cache = JCS.getInstance(regionName);
> cache.putInGroup(key, groupName, value);
> Set keys = cache.getGroupKeys(groupName)

This is the actual trick. Just invent some group name and put all your
keys and values into that group. Then you can get a list of keys by
calling getGroupKeys(). It would be more or less an additional wrapper
in your region.

Bye, Thomas.

To unsubscribe, e-mail:
For additional commands, e-mail:

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message