Allow cache.<name>.diskLimit = 0 to disable on disk cache

Being able to make the on disk cache disabled for only some caches
is more useful than being able to make the on disk cache unlimited
in size.  Ehcache isn't that efficient at writing elements out to
the disk, and since this is strictly a cache, it should always have
a reasonable bound placed on its contents.

Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
Shawn O. Pearce
2009-08-17 07:05:03 -07:00
parent 73a79cab4f
commit a5e36d59ac
2 changed files with 4 additions and 3 deletions

View File

@@ -182,7 +182,8 @@ cache.<name>.diskLimit::
+ +
Maximum number of cache items to retain on disk, if this cache Maximum number of cache items to retain on disk, if this cache
supports storing its items to disk. Like memoryLimit, this is supports storing its items to disk. Like memoryLimit, this is
total number of items, not bytes of disk used. total number of items, not bytes of disk used. If 0, disk storage
for this cache is disabled.
+ +
Default is 16384. Default is 16384.

View File

@@ -159,8 +159,8 @@ public class CacheManagerProvider implements Provider<CacheManager> {
int buffer = c.getDiskSpoolBufferSizeMB() * MB; int buffer = c.getDiskSpoolBufferSizeMB() * MB;
buffer = config.getInt("cache", name, "diskbuffer", buffer) / MB; buffer = config.getInt("cache", name, "diskbuffer", buffer) / MB;
c.setDiskSpoolBufferSizeMB(Math.max(1, buffer)); c.setDiskSpoolBufferSizeMB(Math.max(1, buffer));
c.setOverflowToDisk(true); c.setOverflowToDisk(c.getMaxElementsOnDisk() > 0);
c.setDiskPersistent(true); c.setDiskPersistent(c.getMaxElementsOnDisk() > 0);
} }
return c; return c;
} }