Documentation
¶
Overview ¶
Package datastore provides Google Cloud Datastore persistence for sfcache.
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]) Len(ctx context.Context) (int, error)
- func (s *Store[K, V]) Location(key K) string
- 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 ¶
New creates a new Datastore-based persistence layer. The cacheID is used as the Datastore database name. An empty projectID will be auto-detected from the environment.
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]) 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]) ValidateKey ¶
ValidateKey checks if a key is valid for Datastore persistence. Datastore has stricter key length limits than files.