store

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 8 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Datastore

type Datastore struct {
	Backend Storer
	// contains filtered or unexported fields
}

Datastore represents a generic data store that abstracts the underlying storage backend.

func NewDatastore added in v1.4.0

func NewDatastore(backend Storer, cfg *config.Config) *Datastore

NewDatastore creates a new instance of Datastore with the provided backend and configuration.

func (*Datastore) ConvertRedirectFormatToForwardLookupOnly added in v1.4.0

func (ds *Datastore) ConvertRedirectFormatToForwardLookupOnly(ctx context.Context, key string) error

ConvertRedirectFormatToForwardLookupOnly converts a dual index redirect format to a forward lookup only format in the datastore.

func (*Datastore) ConvertRedirectFormatToReverseLookup added in v1.4.0

func (ds *Datastore) ConvertRedirectFormatToReverseLookup(ctx context.Context, key string) error

ConvertRedirectFormatToReverseLookup converts a forward lookup redirect format to a dual index format allowing reverse lookup in the datastore.

func (*Datastore) DeleteRedirect added in v1.4.0

func (ds *Datastore) DeleteRedirect(ctx context.Context, redirectID string) error

DeleteRedirect removes a redirect and its reverse lookup entry from the datastore based on the provided redirectID.

func (*Datastore) DeleteValue deprecated added in v0.3.3

func (ds *Datastore) DeleteValue(ctx context.Context, redirectID string) error

DeleteValue removes a value from the datastore based on the provided redirectID.

Deprecated: Use DeleteRedirect instead.

func (*Datastore) GetKeys added in v1.4.0

func (ds *Datastore) GetKeys(ctx context.Context, matchPattern string, count int64, cursor uint64) (keys []string, newCursor uint64, err error)

GetKeys retrieves a set of keys from the datastore based on the specified match pattern, count, and cursor for pagination.

func (*Datastore) GetRedirect

func (ds *Datastore) GetRedirect(ctx context.Context, redirectID string) (string, error)

GetRedirect retrieves a redirect value from the datastore based on the provided redirectID. When reverse lookup is enabled the redirect is stored under the forward lookup prefix, so the key is prefixed before reading. The error is returned unwrapped so that callers can compare it against disRedis.ErrKeyNotFound.

func (*Datastore) GetRedirects added in v0.3.5

func (ds *Datastore) GetRedirects(ctx context.Context, to string, count int64, cursor uint64) (keyValuePairs map[string]string, newCursor uint64, err error)

GetRedirects retrieves a list of redirects from the datastore. If the 'to' parameter is provided, it retrieves redirects pointing to the specified destination. Otherwise, it retrieves all redirects with pagination support.

func (*Datastore) GetSetMemberValues added in v1.4.0

func (ds *Datastore) GetSetMemberValues(ctx context.Context, setKey, matchPattern, valuePrefix string, count int64, cursor uint64) (keyValuePairs map[string]string, newCursor uint64, err error)

GetSetMemberValues retrieves the values of members in a set from the datastore based on the provided set key and optional match pattern and value prefix.

func (*Datastore) GetTotalCount added in v0.3.5

func (ds *Datastore) GetTotalCount(ctx context.Context, to string) (totalCount int, err error)

GetTotalCount retrieves the total count of redirects from the datastore. If the 'to' parameter is provided, it retrieves the count of redirects pointing to the specified destination. Otherwise, it retrieves the total count of all redirects.

func (*Datastore) GetValue added in v0.3.2

func (ds *Datastore) GetValue(ctx context.Context, redirectID string) (string, error)

GetValue retrieves a value from the datastore based on the provided redirectID. This is the raw key accessor and deliberately applies no prefix, regardless of the reverse lookup flag: its callers either pass an already prefixed key or intend to read the unprefixed one. Use GetRedirect for prefix aware redirect lookups.

func (*Datastore) UpsertRedirect added in v1.4.0

func (ds *Datastore) UpsertRedirect(ctx context.Context, from, to string) error

UpsertRedirect inserts or updates a redirect in the datastore with the specified 'from' and 'to' values.

func (*Datastore) UpsertValue deprecated added in v0.3.2

func (ds *Datastore) UpsertValue(ctx context.Context, key string, value interface{}, expiration time.Duration) error

UpsertValue inserts or updates a value in the datastore with the specified key, value, and expiration time.

Deprecated: Use UpsertRedirect instead.

type ForwardLookupOnlyReconciler added in v1.4.0

type ForwardLookupOnlyReconciler struct {
	// contains filtered or unexported fields
}

ForwardLookupOnlyReconciler is a reconciler that ensures only forward lookup keys are maintained for stored redirects.

func NewForwardLookupOnlyReconciler added in v1.4.0

func NewForwardLookupOnlyReconciler(ds *Datastore) *ForwardLookupOnlyReconciler

NewForwardLookupOnlyReconciler creates a new instance of ForwardLookupOnlyReconciler.

func (*ForwardLookupOnlyReconciler) Reconcile added in v1.4.0

func (r *ForwardLookupOnlyReconciler) Reconcile(ctx context.Context) (int, error)

Reconcile will convert all stored redirects to use only forward lookup keys and remove any reverse lookup keys.

type Reconciler added in v1.4.0

type Reconciler interface {
	Reconcile(ctx context.Context) (int, error)
}

Reconciler defines the interface for a component that can reconcile stored records.

type Redis

type Redis interface {
	Checker(context.Context, *healthcheck.CheckState) error
	// contains filtered or unexported methods
}

Redis represents all the required methods from Redis

type ReverseLookupReconciler added in v1.4.0

type ReverseLookupReconciler struct {
	// contains filtered or unexported fields
}

ReverseLookupReconciler is a reconciler that ensures reverse lookup keys are correctly maintained for stored redirects.

func NewReverseLookupReconciler added in v1.4.0

func NewReverseLookupReconciler(ds *Datastore) *ReverseLookupReconciler

NewReverseLookupReconciler creates a new instance of ReverseLookupReconciler.

func (*ReverseLookupReconciler) Reconcile added in v1.4.0

func (r *ReverseLookupReconciler) Reconcile(ctx context.Context) (int, error)

Reconcile will convert all stored redirects to use fwd prefix and add a reverse lookup via the rev prefix

type Storer

type Storer interface {
	// contains filtered or unexported methods
}

Storer represents basic data access via Get, Remove and Upsert methods, abstracting it from Redis

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL