Skip to content

Annotations for invalidating cache entries on update #2

@bjarkih

Description

@bjarkih

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 > 0 then we reset the cached entry determined by (x_1, ..., x_N).
  • If N = 0 we reset the cached entry determined by y treating the function as f(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 > 0 then we reset the cached entry determined by (x_1, ..., x_N).
  • If N = 0 we 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 > 0 then we reset the cached entry determined by (x_1, ..., x_N).
  • If N = 0 we clear the whole cache block.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions