Skip to content

Allow cache disabling #74

@DT209

Description

@DT209

I am trying to temporarily disable (by disable I mean: act as if caching was turned off entirely) a set of cache2k caches and there seems to be no way to do this with the default implementation at "runtime" (and by runtime I mean after the cache has been created and potentially populated). So I thought I would provide a new Cache (possibly using the existing cache implementation along with org.cache2k.ForwardingCache and just wrapping each call to act as I would expect if disabled). Please note that I am not using any loader functionality (and would like not to).

How do I register a new cache implementation within cache2k? Is there a better way to do this without using a loader?

Ideally I would like to do something like this:
CacheManager.getInstance().getActiveCaches().forEach(cache -> {cache.enable();});
and this
CacheManager.getInstance().getActiveCaches().forEach(cache -> {cache.clear(); cache.disable();});

Originally from discussion at StackOverlow

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions