package state import ( "context" "time" ) func NewStateCache(ttl time.Duration, store Store) *StateCache { return &StateCache{ TTL: ttl, Store: store, } } var _ Cache = (*StateCache)(nil) type StateCache struct { Store Store TTL time.Duration } func (s *StateCache) Set(ctx context.Context, key Key, state []byte) error { return s.Store.Set(ctx, key, state, WithTTL(s.TTL)) } func (s *StateCache) Get(ctx context.Context, key Key) (state []byte, meta Metadata, err error) { if s == nil { return nil, Metadata{}, nil } return s.Store.Get(ctx, key) }