Alachisoft NCache 4.1 - Online Documentation

Finding Items

 
Items can be retrieved from the cache either by using Get method or cache indexer. Both methods are explained below with examples. Include the following import statement in your project:
 
 
import com.alachisoft.ncache.web.caching.*;
 
Using Get Method
 
Here is how you can retrieve items from the cache.
 
 
Cache _cache = NCache.initializeCache("myCache");
//returns null if item not found
Object myObject = _cache.get("Customer:David:1001");
if(myObject == null)
{
//item not found
}
 
Using Contains Method
 
You can also check whether an item exists in the cache or not.
 
 
Cache _cache = NCache.initializeCache("myCache");
//Returns true or false
if(_cache.contains("Customer:David:1001"))
{
//item found
}
 
 
 
See Also
 
Copyright © 2005-2012 Alachisoft. All rights reserved.