-
Notifications
You must be signed in to change notification settings - Fork 582
dev.meetings
Next public meeting on G+ Hangout on Air at 11:30 IST / 8pm CET / 2pm EST / 11am PST
final CacheManager cacheManager = newCacheManagerBuilder().build();
final PersistentCacheManager pCacheManager = newCacheManagerBuilder()
.as(
diskPersistent(OVERRIDING)
.persistTo(File.createTempFile("ehcache", ".data"))
)
.build();
final PersistentCache<String, Object> pCache = newCacheBuilder(String.class, Object.class)
.as(
persistent(String.class, Object.class)
)
.build();
Recording available here on YouTube
Let’s try to introduce a type hierarchy for both Cache and CacheManager that the builder would actually build, narrowing the type down à la Quartz 2.0 builders.
PersistentCache cache = newCacheBuilder() // (1)
.diskPersistent(
cfg // (3)
) // (2)
.build(); // (4)
-
static method that creates a builder: Builder<Cache>
-
narrows to the builder’s type down to Builder<PersistentCache>
-
cfg actually defines the mode to use for persistence, eg: expect data on disk; expect none; use data if there; wipe data if there; wipe data on Cache.close()
-
actually builds the PersistentCache
Alex to make an actual proposal by next week.
-
Keep these, where the user is actually responsible to provide services
-
Only these Cache's type would expose .close()
-
CacheManager managed Cache instances would be 'closed' through the CacheManager
-
To further lifecycle PersistentCache instance, managed by a CacheManager, the latter could expose some method to retrieve DiskPersisted (interface with minimal lifecycle methods) instances; e.g.
Iterable<Map.Entry<String, DiskPersisted>> it = cacheManager.getManaged(DiskPersisted.class); it.next().value() // (1) .deleteOnDiskFiles(); // (2)
-
DiskPersisted could expose methods around lifecycling the data on disk only. No Cache methods
-
Implies Cache.close(), i.e. clear all 'VM transient' data and delete data from disk.
Recording available here on YouTube