cache

package
v2.4.3 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigStorage

type ConfigStorage interface {
	// GetStorageEngine returns the storage engine name used for this cache config
	GetStorageEngine() string

	// GetStoragePath returns the full path to the storage bucket (file path or database URI)
	GetStoragePath() string

	// GetStorageVersion returns the storage version used for this cache
	GetStorageVersion() string

	// Save writes the cache config
	Save() error

	// Read loads the cache config
	Read() error
}

ConfigStorage is the interface that all cache config objects must implement, it's used to save or load cache config, from disk, database, or just RAM for the in-memory cache.

type JSONConfigFile

type JSONConfigFile struct {
	ConfigVersion  string `json:"config_version"`  // The schema version of this cache index file.
	StorageEngine  string `json:"storage_engine"`  // The storage engine used for this cache
	StorageVersion string `json:"storage_version"` // The storage version used for this cache
	StoragePath    string `json:"storage_path"`    // The full path to the storage bucket (file path or database URI)
	// contains filtered or unexported fields
}

JSONConfigFile is a struct that backs a llm_proxy_cache.json file, which configures the cache storage object

func NewStorageJSON

func NewStorageJSON(
	logger *slog.Logger,
	cacheDir string,
	defaultCacheConfigVer, cacheConfigFileName, currentStorageVersion, defaultStorageEngineName string,
) (*JSONConfigFile, error)

NewStorageJSON creates a new IndexFile object to help with loading/saving meta-state as a json file. This object's purpose is to help loading the other database objects by pointing to their connection settings or file paths.

cacheDir: the directory where the cache index file will be stored

func (JSONConfigFile) GetStorageEngine

func (i JSONConfigFile) GetStorageEngine() string

GetStorageEngine returns the storage engine used for this cache

func (JSONConfigFile) GetStoragePath

func (i JSONConfigFile) GetStoragePath() string

GetStoragePath returns the full path to the storage bucket (file path or database URI)

func (JSONConfigFile) GetStorageVersion

func (i JSONConfigFile) GetStorageVersion() string

GetStorageVersion returns the storage version used for this cache

func (*JSONConfigFile) Read

func (i *JSONConfigFile) Read() error

Read reads the cache config json file from disk

func (JSONConfigFile) Save

func (i JSONConfigFile) Save() error

Save writes the cache config json file to disk

type MemoryConfig

type MemoryConfig struct {
}

MemoryConfig is a mostly empty struct that implements the Config interface for an in-memory cache

func NewMemoryConfig

func NewMemoryConfig() *MemoryConfig

NewMemoryConfig creates a new (empty) MemoryConfig object to implement the cache.ConfigStorage interface

func (*MemoryConfig) GetStorageEngine

func (m *MemoryConfig) GetStorageEngine() string

GetStorageEngine returns the storage engine type

func (*MemoryConfig) GetStoragePath

func (m *MemoryConfig) GetStoragePath() string

GetStoragePath returns the storage path, which is RAM for this implementation

func (*MemoryConfig) GetStorageVersion

func (m *MemoryConfig) GetStorageVersion() string

GetStorageVersion returns the storage version

func (*MemoryConfig) Read

func (m *MemoryConfig) Read() error

Read loads the cache config, which is a noop for this implementation

func (*MemoryConfig) Save

func (m *MemoryConfig) Save() error

Save writes the cache config, which is a noop for this implementation

Jump to

Keyboard shortcuts

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