apache / apache/gravitino

[Subtask] Add an optional Redis shared entity cache implementation

Open
#12,020 12 comments 0 reactions 1 assignee Claimed by @ealeonraz View on GitHub
subtask
Dominant language
Java
Stars
3.2k
Forks
935
Avg merge
1d 17h
Merged PRs (30d)
339

Description

### Describe the subtask

Add an optional `redis` entity cache behind the same SPI for deployments that want strong (read-your-writes) consistency by keeping one cluster-wide copy instead of one copy per node. It is selected by `gravitino.cache.impl=redis`; the default stays `caffeine`. Because relation data is no longer cached (#11961), the shared cache only needs to store single-entity entries, which keeps this implementation simple.

This subtask should:

- Add `RedisEntityCache` with `coherence() = SHARED`: store entity values as `D:{key}` strings, plus an `IDX` ZSet forward index used only for the hierarchical-drop prefix range (`ZRANGEBYLEX`); no reverse index.
- Implement get / put / invalidate / clear, and run a container drop plus the delete-then-stale-write guard as a version-checked Lua script, so a reader never sees a half-done drop and a stale write cannot overwrite a newer value.
- Register `"redis" -> RedisEntityCache.class` in `CacheFactory` and add the config keys (`address`, `namespace`, `ttl`, `serializer`); callers do not change.
- Add integration tests with a Redis container: cross-node freshness, container drop via `ZRANGEBYLEX`, and rejection of a stale write after a committed newer value.

This delivers Phase 2 of #11737. If the change grows beyond a comfortably reviewable size, the integration tests can be split into a follow-up.

### Parent issue

https://github.com/apache/gravitino/issues/11737

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.