backends

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 23, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileSystemBackend

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

FileSystemBackend implements storage using the local file system

func NewFileSystemBackend

func NewFileSystemBackend() *FileSystemBackend

NewFileSystemBackend creates a new file system storage backend

func (*FileSystemBackend) Close

func (fs *FileSystemBackend) Close() error

Close cleans up resources (no-op for file system)

func (*FileSystemBackend) Delete

func (fs *FileSystemBackend) Delete(ctx context.Context, key string) error

Delete removes data from the file system for the given key/path

func (*FileSystemBackend) Exists

func (fs *FileSystemBackend) Exists(ctx context.Context, key string) (bool, error)

Exists checks if data exists at the given key/path

func (*FileSystemBackend) Init

func (fs *FileSystemBackend) Init(config map[string]interface{}) error

Init initializes the file system backend with configuration

func (*FileSystemBackend) List

func (fs *FileSystemBackend) List(ctx context.Context, prefix string) ([]string, error)

List returns a list of keys with the given prefix

func (*FileSystemBackend) Load

func (fs *FileSystemBackend) Load(ctx context.Context, key string) (io.ReadCloser, error)

Load retrieves data from the file system for the given key/path

func (*FileSystemBackend) Save

func (fs *FileSystemBackend) Save(ctx context.Context, key string, data io.Reader) error

Save stores data to the file system at the specified key/path

type MemoryBackend

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

MemoryBackend implements in-memory storage for testing and temporary use

func NewMemoryBackend

func NewMemoryBackend() *MemoryBackend

NewMemoryBackend creates a new in-memory storage backend

func (*MemoryBackend) BatchDelete

func (m *MemoryBackend) BatchDelete(ctx context.Context, keys []string) error

BatchDelete removes multiple keys in a single operation

func (*MemoryBackend) BatchSave

func (m *MemoryBackend) BatchSave(ctx context.Context, items map[string]io.Reader) error

BatchSave saves multiple key-value pairs in a single operation

func (*MemoryBackend) Clear

func (m *MemoryBackend) Clear()

Clear removes all data from the backend

func (*MemoryBackend) Clone

func (m *MemoryBackend) Clone() *MemoryBackend

Clone creates a deep copy of the memory backend

func (*MemoryBackend) Close

func (m *MemoryBackend) Close() error

Close cleans up resources (clears memory)

func (*MemoryBackend) Delete

func (m *MemoryBackend) Delete(ctx context.Context, key string) error

Delete removes data from memory for the given key

func (*MemoryBackend) Exists

func (m *MemoryBackend) Exists(ctx context.Context, key string) (bool, error)

Exists checks if data exists at the given key in memory

func (*MemoryBackend) GetSize

func (m *MemoryBackend) GetSize(ctx context.Context, key string) (int64, error)

GetSize returns the size of data stored at the given key

func (*MemoryBackend) Init

func (m *MemoryBackend) Init(config map[string]interface{}) error

Init initializes the memory backend (no-op, but maintains interface compatibility)

func (*MemoryBackend) Keys

func (m *MemoryBackend) Keys() []string

Keys returns all keys currently stored

func (*MemoryBackend) List

func (m *MemoryBackend) List(ctx context.Context, prefix string) ([]string, error)

List returns a list of keys with the given prefix

func (*MemoryBackend) Load

func (m *MemoryBackend) Load(ctx context.Context, key string) (io.ReadCloser, error)

Load retrieves data from memory for the given key

func (*MemoryBackend) MemoryUsage

func (m *MemoryBackend) MemoryUsage() int64

MemoryUsage returns the approximate memory usage in bytes

func (*MemoryBackend) Save

func (m *MemoryBackend) Save(ctx context.Context, key string, data io.Reader) error

Save stores data in memory at the specified key

func (*MemoryBackend) Size

func (m *MemoryBackend) Size() int

Size returns the number of items stored

type RedisBackend

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

RedisBackend implements storage using Redis for metadata and small objects Note: Redis is better suited for metadata storage rather than large binary objects

func NewRedisBackend

func NewRedisBackend() *RedisBackend

NewRedisBackend creates a new Redis storage backend

func (*RedisBackend) AddToSet

func (r *RedisBackend) AddToSet(ctx context.Context, key string, member interface{}) error

AddToSet adds a member to a set

func (*RedisBackend) Close

func (r *RedisBackend) Close() error

Close closes the Redis connection

func (*RedisBackend) Delete

func (r *RedisBackend) Delete(ctx context.Context, key string) error

Delete removes data from Redis for the given key

func (*RedisBackend) Exists

func (r *RedisBackend) Exists(ctx context.Context, key string) (bool, error)

Exists checks if data exists at the given key in Redis

func (*RedisBackend) GetMetadata

func (r *RedisBackend) GetMetadata(ctx context.Context, key string) (map[string]interface{}, error)

GetMetadata retrieves metadata for a key

func (*RedisBackend) GetSetMembers

func (r *RedisBackend) GetSetMembers(ctx context.Context, key string) ([]string, error)

GetSetMembers returns all members of a set

func (*RedisBackend) GetTTL

func (r *RedisBackend) GetTTL(ctx context.Context, key string) (int64, error)

GetTTL returns the time to live for a key

func (*RedisBackend) Increment

func (r *RedisBackend) Increment(ctx context.Context, key string) (int64, error)

Increment atomically increments a counter key

func (*RedisBackend) Init

func (r *RedisBackend) Init(config map[string]interface{}) error

Init initializes the Redis backend with configuration

func (*RedisBackend) List

func (r *RedisBackend) List(ctx context.Context, prefix string) ([]string, error)

List returns a list of keys with the given prefix

func (*RedisBackend) Load

func (r *RedisBackend) Load(ctx context.Context, key string) (io.ReadCloser, error)

Load retrieves data from Redis for the given key

func (*RedisBackend) Save

func (r *RedisBackend) Save(ctx context.Context, key string, data io.Reader) error

Save stores data to Redis at the specified key

func (*RedisBackend) SetExpiration

func (r *RedisBackend) SetExpiration(ctx context.Context, key string, seconds int) error

SetExpiration sets an expiration time for a key

func (*RedisBackend) SetMetadata

func (r *RedisBackend) SetMetadata(ctx context.Context, key string, metadata map[string]interface{}) error

SetMetadata stores metadata for a key (using hash)

type S3Backend

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

S3Backend implements storage using AWS S3 or S3-compatible services

func NewS3Backend

func NewS3Backend() *S3Backend

NewS3Backend creates a new S3 storage backend

func (*S3Backend) Close

func (s3b *S3Backend) Close() error

Close cleans up resources (no-op for S3)

func (*S3Backend) Delete

func (s3b *S3Backend) Delete(ctx context.Context, key string) error

Delete removes data from S3 for the given key

func (*S3Backend) Exists

func (s3b *S3Backend) Exists(ctx context.Context, key string) (bool, error)

Exists checks if data exists at the given key in S3

func (*S3Backend) GetObjectMetadata

func (s3b *S3Backend) GetObjectMetadata(ctx context.Context, key string) (map[string]interface{}, error)

GetObjectMetadata returns metadata for an S3 object

func (*S3Backend) GetObjectSize

func (s3b *S3Backend) GetObjectSize(ctx context.Context, key string) (int64, error)

GetObjectSize returns the size of an object in S3

func (*S3Backend) Init

func (s3b *S3Backend) Init(config map[string]interface{}) error

Init initializes the S3 backend with configuration

func (*S3Backend) List

func (s3b *S3Backend) List(ctx context.Context, prefix string) ([]string, error)

List returns a list of keys with the given prefix

func (*S3Backend) Load

func (s3b *S3Backend) Load(ctx context.Context, key string) (io.ReadCloser, error)

Load retrieves data from S3 for the given key

func (*S3Backend) Save

func (s3b *S3Backend) Save(ctx context.Context, key string, data io.Reader) error

Save stores data to S3 at the specified key

Jump to

Keyboard shortcuts

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