Skip to content

Draft: Client side caching #1001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: series/1.x
Choose a base branch
from

Conversation

a-khakimov
Copy link

This is a draft implementation of Client Side Caching - #998.
This is roughly how I envision the interface — I’ll finish it soon and add usage examples.
Feel free to take a look; any questions or suggestions are very welcome!

@a-khakimov a-khakimov force-pushed the client_side_caching branch 2 times, most recently from 7ca2e86 to 7b85754 Compare April 23, 2025 18:34
@a-khakimov a-khakimov force-pushed the client_side_caching branch from 7b85754 to 29e7129 Compare April 23, 2025 18:36
@a-khakimov a-khakimov marked this pull request as draft April 23, 2025 18:36
object ClientSideCaching {

def make[F[_]: Async, K, V](
connection: StatefulRedisConnection[K, V],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


def make[F[_]: Async, K, V](
connection: StatefulRedisConnection[K, V],
args: TrackingArgs,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the convention in this lib , is to create a scala api for the java pojo's . i.e.

args: TrackingArgs,
cacheAccessor: CacheAccessor[F, K, V]
): Resource[F, JCacheFrontend[K, V]] =
TxExecutor.make[F].flatMap { redisExecutor =>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

putting aside the changes to TxExecutor, we should create a facade for CacheFrontend similar to CacheAccessor and not require a Dispatcher and unsafeRun


private[redis4cats] trait TxExecutor[F[_]] {
def delay[A](thunk: => A): F[A]
def eval[A](fa: F[A]): F[A]
def start[A](fa: F[A]): F[Fiber[F, Throwable, A]]
def liftK[G[_]: Async]: TxExecutor[G]
def liftK[G[_]: Async: Dispatcher]: TxExecutor[G]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would be a breaking change as it adds additional parameters.
I dont think TxExecutor is the right place for this, it is meant for Redis transactions

Copy link
Member

@gvolpe gvolpe Apr 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add that Dispatcher is not meant to be used as a typeclass, i.e. it should be passed explicitly

@yisraelU
Copy link
Collaborator

In general , I don't like Lettuce's implementation that forces a separate interface for cached values vs uncached.
I'd prefer to see something like injecting a CacheAccessor into the RedisClient creation , and allowing the internals to understand when a command is cacheable or not .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants