datastore

package
v0.0.0-...-6f8bca6 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cloud

type Cloud struct {
	Client     *storage.Client
	BucketName string
}

Cloud is an implementation of DataStore using a Google Cloud Storage bucket.

func (Cloud) Get

func (s Cloud) Get(ctx context.Context, name string) ([]byte, error)

func (Cloud) Has

func (s Cloud) Has(ctx context.Context, name string) (bool, error)

func (Cloud) Put

func (s Cloud) Put(ctx context.Context, name string, value []byte) error

type DataStore

type DataStore interface {
	Get(ctx context.Context, name string) ([]byte, error)
	Put(ctx context.Context, name string, value []byte) error
	// TODO: return size
	Has(ctx context.Context, name string) (bool, error)
}

DataStore is an interface defining low-level operations for handling unstructured key/value pairs. At this level, there is no concept of digest or any structure of the values.

type File

type File struct {
	DirName string
}

File is an implementation of DataStore using the local file system, rooted at the specified directory.

func (File) Get

func (s File) Get(ctx context.Context, name string) ([]byte, error)

func (File) Has

func (s File) Has(ctx context.Context, name string) (bool, error)

func (File) Put

func (s File) Put(ctx context.Context, name string, value []byte) error

type InMemory

type InMemory struct {
	Inner map[string][]byte
}

func (InMemory) Get

func (s InMemory) Get(ctx context.Context, name string) ([]byte, error)

func (InMemory) Has

func (s InMemory) Has(ctx context.Context, name string) (bool, error)

func (InMemory) Put

func (s InMemory) Put(ctx context.Context, name string, value []byte) error

type Memcache

type Memcache struct {
	Inner DataStore
	RDB   *redis.Client
}

func (Memcache) Get

func (s Memcache) Get(ctx context.Context, name string) ([]byte, error)

func (Memcache) Has

func (s Memcache) Has(ctx context.Context, name string) (bool, error)

func (Memcache) Put

func (s Memcache) Put(ctx context.Context, name string, value []byte) error

func (Memcache) TrySet

func (s Memcache) TrySet(ctx context.Context, name string, value []byte)

Jump to

Keyboard shortcuts

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