kvcache

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client provides cache-based storage operations where files are stored in a byte cache. This is useful for temporary storage or small files that benefit from fast cache access.

func NewClient

func NewClient(conf Config, cache cache.ByteCache) (*Client, error)

NewClient creates a new cache-based storage client with the provided configuration and cache backend. If no expiration time is specified, files are cached indefinitely.

func (*Client) CopyFile

func (c *Client) CopyFile(ctx context.Context, sourceKey string, destinationKey string, overwrite bool) error

CopyFile duplicates a file from source to destination key within cache storage. Validates overwrite permissions and handles cache expiration settings.

func (*Client) DeleteFile

func (c *Client) DeleteFile(ctx context.Context, key string) error

DeleteFile removes a file from the cache storage.

func (*Client) DownloadFile

func (c *Client) DownloadFile(ctx context.Context, key string) (storage.DownloadResult, error)

DownloadFile retrieves file data from the cache storage. Returns the file content reader, MIME type based on file extension, and content size.

func (*Client) IsFileExists

func (c *Client) IsFileExists(ctx context.Context, key string) (bool, error)

IsFileExists checks whether a file exists in the cache storage.

func (*Client) MoveFile

func (c *Client) MoveFile(ctx context.Context, sourceKey string, destinationKey string, overwrite bool) error

MoveFile relocates a file from source to destination key within cache storage. This operation copies the file content and then deletes the source.

func (*Client) UploadFile

func (c *Client) UploadFile(ctx context.Context, file io.Reader, key string) (string, error)

UploadFile stores file data in the cache with the specified key and expiration time.

func (*Client) UploadLocalFile

func (c *Client) UploadLocalFile(ctx context.Context, file string, key string) (string, error)

UploadLocalFile reads a local file and stores it in the cache with the specified key.

type Config

type Config struct {
	Expires *time.Duration `json:"expires" yaml:"expires"`
}

Config holds the configuration for cache-based storage operations.

Jump to

Keyboard shortcuts

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