CacheObject o = new CacheObject(name, object, objGr, region, CacheImpl.getCache().getReferenceQueue());
o.setAttributes(attributes);
int maxObjects = CacheImpl.getCache().getAttributes().getMaxObjects();
int currentObjectCount = getCurrentObjectCount();
if (currentObjectCount >= maxObjects) {
DiskCache diskCache = CacheImpl.getCache().getDiskCache();
if (diskCache == null) {
//no disk, and memory is full.
this.lastException = CacheFullException.class;
this.lastMessage = "The maximum number of objects in the cache has been reached.";
return false;
}
boolean updated = diskCache.update(o);
if (!updated) {
this.lastException = CacheFullException.class;
this.lastMessage = "The maximum size for the diskCache has been reached.";
}
return updated;
}
if ((attributes != null) && (attributes.getSize() != 0)) {
if ((region.getCurrentSize() + attributes.getSize()) > (CacheImpl.getCache().getAttributes().getMemoryCacheSize() * 1024 * 1024)) {
DiskCache diskCache = CacheImpl.getCache().getDiskCache();
if (diskCache == null) {
//no disk, and memory is full.
this.lastException = CacheFullException.class;
this.lastMessage = "The maximum size for the memory cache has been reached.";
return false;
}
boolean updated = diskCache.update(o);
if (!updated) {
this.lastException = CacheFullException.class;
this.lastMessage = "The maximum size for the diskCache has been reached.";
}
return updated;