Ashwin Karki
Ashwin Karki

Reputation: 269

How to get all the data from cache in java?

Here, I am using the Java Caching System (JCS). I can put and get data in the cache. I need the whole data set for example like a key-value pair. Please guide me a way to retrieve it.

package net.practice.so;

import org.apache.jcs.JCS;
import org.apache.jcs.access.exception.CacheException;
import org.apache.jcs.engine.control.CompositeCacheManager;

import java.util.Properties;

public class JcsPractice {

    public static void main(String[] args) throws CacheException {

        CompositeCacheManager ccm = CompositeCacheManager.getUnconfiguredInstance();
        Properties props = new Properties();
        props.put("jcs.default", "DC");
        ccm.configure(props);

        JCS cache = JCS.getInstance("numberCache");
        cache.put(1, "one");
        cache.put(2, "two");
        cache.put(3, "three");

        System.out.println(cache.get(2));
    }

}

Upvotes: 1

Views: 1223

Answers (0)

Related Questions