Repository navigation
State
cuihairu edited this page Dec 28, 2025
·
2 revisions
Module: state/
Distributed state primitives: Value/Map/List/Set state and backends.
- 提供
core层状态抽象的具体实现(Redis-backed) - 说明:
runtime目前的 keyed state 为 in-memory 实现;与state/的端到端集成仍在演进中
io.github.cuihairu.redis.streaming.state.backend.StateBackendio.github.cuihairu.redis.streaming.state.redis.RedisStateBackend
import io.github.cuihairu.redis.streaming.api.state.StateDescriptor;
import io.github.cuihairu.redis.streaming.api.state.ValueState;
import io.github.cuihairu.redis.streaming.state.redis.RedisStateBackend;
import org.redisson.Redisson;
import org.redisson.config.Config;
Config cfg = new Config();
cfg.useSingleServer().setAddress("redis://127.0.0.1:6379");
var redisson = Redisson.create(cfg);
RedisStateBackend backend = new RedisStateBackend(redisson, "state:demo:");
ValueState<Integer> counter = backend.createValueState(new StateDescriptor<>("counter", Integer.class));
Integer v = counter.value();
counter.update(v == null ? 1 : v + 1);- Design.md