Files
orm/cache_noop.go
zeekay 354ada4523 Add KV cache layer with memory and Redis/Valkey backends
Entity cache (orm:{ns}:{kind}:{id}) and query cache
(orm:{ns}:{kind}:q:{hash}) with configurable TTL.
Backends: in-memory LRU, Redis/Valkey via kv-go, and no-op.
2026-02-23 16:18:53 -08:00

40 lines
864 B
Go

package orm
import (
"context"
"time"
)
// NoopCache is a cache layer that does nothing. Used when caching is disabled.
type NoopCache struct{}
var _ CacheLayer = (*NoopCache)(nil)
func (c *NoopCache) GetEntity(_ context.Context, _, _ string) ([]byte, bool, error) {
return nil, false, nil
}
func (c *NoopCache) SetEntity(_ context.Context, _, _ string, _ []byte, _ time.Duration) error {
return nil
}
func (c *NoopCache) InvalidateEntity(_ context.Context, _, _ string) error {
return nil
}
func (c *NoopCache) InvalidateKind(_ context.Context, _ string) error {
return nil
}
func (c *NoopCache) GetQuery(_ context.Context, _, _ string) ([]byte, bool, error) {
return nil, false, nil
}
func (c *NoopCache) SetQuery(_ context.Context, _, _ string, _ []byte, _ time.Duration) error {
return nil
}
func (c *NoopCache) Close() error {
return nil
}