Thanks to visit codestin.com
Credit goes to github.com

Skip to content

RFC: unify hybrid cache get/obtain/fetch APIs #1144

@MrCroxx

Description

@MrCroxx

At present, foyer implements different levels of get operations through three interfaces: get/obtain/fetch:

  1. The get operation does not require the key to be cloneable.
  2. The obtain operation requires the key to be cloneable and performs deduplication optimization on requests.
  3. The fetch interface requires the key to be cloneable, and an additional fetch future needs to be passed in. It performs deduplication optimization on requests, as well as automatic cache fill and other optimizations.

This design is a bit complex, and it does not directly provide a shortcut for a pure in-memory path.

To simplify the design and make the interface more user-friendly, we are considering refactoring the read-related interfaces.

e.g.

All read interfaces return:

enum Get<K, V, P> {
  Hit { key: K, value: V, properties: P},
  Fetch { future: Box<dyn Future<Output = Result<(K, V, P)>>>},
}

If get() hits directly on the pure in-memory path, Get returns directly through the Hit branch. Get implements Future, and whether it is the Hit or Fetch path, it supports poll to unify the asynchronous interface.

If get() hits directly on the pure in-memory path, Get returns directly through the Hit branch. Get implements Future, and whether it is the Hit or Fetch path, it supports poll to unify the asynchronous interface.

Metadata

Metadata

Assignees

Labels

RFCRequest for CommentsfeatureNew feature or requesthelp wantedExtra attention is neededrefactor

Projects

Status

No status

Relationships

None yet

Development

No branches or pull requests

Issue actions