Skip to content

Provide an option to retry a failed cache insert or read #361

@debrutal

Description

@debrutal

Feature description

I would like to be able to retry reading from and writing into Redis, when the connection to redis is lost.

Our current problem is the following:

@Cacheable // (1) InterceptPhase = -100
@Retryable // (2) InterceptPhase = -60
public String getValue(String someParameter){
 // calling remote service that can fail (3)
  return "value"
}
(4)

Explaination:

  1. @Cacheable checks if this method with the given parameter is in our Cache (Redis) If it is found, the cache hit will return immediatly our desired value. This interceptor kicks in first, since its intercept Phase is lower than @Retryable
  2. @Retryable will retry in case of failures of computing our desired value (i.e. calls a remote service). For simplicity reasons it just shall retry on any problem.
  3. Calling a remote service that fails is covered by retryable
  4. When this method return as value @Cacheable will store the result within our cache. Unfortunatly this cache is a remote service, which can also fail. We could see a few Connection reset issues.

Problem / Feature 1: Reading from Redis can fail and should be retried
Problem / Feature 2: Writing into Redis can fail and should be retried

Having this scenario, i would love to see something like

micronaut:
   redis:
      retry: 
        read: 2 # Retry twice on failure
        insert: 2 # This triggers insert retry 

The given example solution is just for inspiration purposes!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions