I am using groovy to process a batch job, I am planning to cache domain object by using groovy's @Memoize annotation, but problem is the expiry, I want to expire the cache when the job is finished. Is there any way to tell groovy to expire the cache from code?
As per the docs,
@Memoized
features only a max value and a protection cache size parameters.Since the AST under the covers will create the memoize mechanism through
Closure::memoize
, you could emulate it with a map and memoized closures which can be disposed:And test: