Documentation
¶
Overview ¶
Package datastore provides Google Cloud Datastore persistence for fido.
Index ¶
- type Store
- func (s *Store[K, V]) Cleanup(ctx context.Context, maxAge time.Duration) (int, error)
- func (s *Store[K, V]) Close() error
- func (s *Store[K, V]) Delete(ctx context.Context, key K) error
- func (s *Store[K, V]) Flush(ctx context.Context) (int, error)
- func (s *Store[K, V]) Get(ctx context.Context, key K) (value V, expiry time.Time, found bool, err error)
- func (s *Store[K, V]) Keys(ctx context.Context, prefix string) iter.Seq[string]
- func (s *Store[K, V]) Len(ctx context.Context) (int, error)
- func (s *Store[K, V]) Location(key K) string
- func (s *Store[K, V]) Range(ctx context.Context, prefix string) iter.Seq2[string, V]
- func (s *Store[K, V]) Set(ctx context.Context, key K, value V, expiry time.Time) error
- func (*Store[K, V]) ValidateKey(key K) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Store ¶
type Store[K comparable, V any] struct { // contains filtered or unexported fields }
Store implements persistence using Google Cloud Datastore.
func New ¶
func New[K comparable, V any](ctx context.Context, cacheID string, c ...compress.Compressor) (*Store[K, V], error)
New creates a new Datastore-based persistence layer. The cacheID is used as the Datastore database name. Optional compressor enables compression (default: no compression).
func (*Store[K, V]) Cleanup ¶
Cleanup removes expired entries from Datastore. maxAge specifies how old entries must be (based on expiry field) before deletion. If native Datastore TTL is properly configured, this will find no entries.
func (*Store[K, V]) Flush ¶
Flush removes all entries from Datastore. Returns the number of entries removed and any error.
func (*Store[K, V]) Get ¶
func (s *Store[K, V]) Get(ctx context.Context, key K) (value V, expiry time.Time, found bool, err error)
Get retrieves a value from Datastore.
func (*Store[K, V]) Keys ¶ added in v1.11.0
Keys returns an iterator over keys matching prefix. Implements PrefixScanner[V] interface (only usable when K is string). Uses Datastore keys-only query for efficiency.
func (*Store[K, V]) Location ¶
Location returns the Datastore key path for a given cache key. Implements the Store interface Location() method. Format: "kind/key" (e.g., "CacheEntry/mykey").
func (*Store[K, V]) Range ¶ added in v1.11.0
Range returns an iterator over key-value pairs matching prefix. Implements PrefixScanner[V] interface (only usable when K is string). Uses Datastore full query to fetch entities.
func (*Store[K, V]) ValidateKey ¶
ValidateKey checks if a key is valid for Datastore persistence. Datastore has stricter key length limits than files.