-
Notifications
You must be signed in to change notification settings - Fork 1
Description
We add new runtime annotations that can be used to decorate methods that should write to or delete from the cache.
Technical details
Cachalot currently does not listen for explicit modifications to entries in the cache blocks it has under administration. The only updates to cache blocks are made upon expiry or overflow. This means that explicit modifications to cached objects are not immediately reflected in the cache.
Cache updates
We add a new CacheUpdate annotation that has the following parameters:
name: Name of the cache block to modify (required).functional: Whether the method call should be treated as a function call.
With the functional flag set, CacheUpdate annotation can be used to decorate functions of the form f(x_1, ..., x_N) = y with the semantics of
assign cache entry (x_1, ..., x_N) a new value of y
The exact implementation of the functional annotation is determined as follows.
No return type
For a method void methodName(x_1, ..., x_N, y) with N + 1 arguments (N >= 0) annotated with CacheUpdate, the cache interceptor will proceed as follows:
- If
N > 0then we reset the cached entry determined by(x_1, ..., x_N). - If
N = 0we reset the cached entry determined byytreating the function asf(y) = const.
A functional CacheUpdate on a method of the form void methodName() will clear the whole cache block.
Return type
For a method T methodName(x_1, ..., x_N) with N arguments (N >= 0) annotated with CacheUpdate, the cache interceptor will proceed as follows:
- If
N > 0then we reset the cached entry determined by(x_1, ..., x_N). - If
N = 0we clear the whole cache block.
Cache removals
We add a new CacheDelete annotation that has the following parameters:
name: Name of the cache block to modify (required).
For a method methodName(x_1, ..., x_N) with N arguments (N >= 0) annotated with CacheDelete, the cache interceptor will proceed as follows:
- If
N > 0then we reset the cached entry determined by(x_1, ..., x_N). - If
N = 0we clear the whole cache block.