Documentation
¶
Index ¶
- func GetMemoryStore(ctx context.Context) (agents.Memory, error)
- func WithMemoryStore(ctx context.Context, store agents.Memory) context.Context
- func WithRedisStore(ctx context.Context, store *RedisStore) context.Context
- type Memory
- type RedisStore
- func (r *RedisStore) CleanExpired(ctx context.Context) (int64, error)
- func (r *RedisStore) Clear() error
- func (r *RedisStore) Close() error
- func (r *RedisStore) List() ([]string, error)
- func (r *RedisStore) Retrieve(key string) (any, error)
- func (r *RedisStore) Store(key string, value any, opts ...agents.StoreOption) error
- func (r *RedisStore) StoreWithTTL(ctx context.Context, key string, value any, ttl time.Duration) error
- type SQLiteStore
- func (s *SQLiteStore) CleanExpired(ctx context.Context) (int64, error)
- func (s *SQLiteStore) Clear() error
- func (s *SQLiteStore) Close() error
- func (s *SQLiteStore) List() ([]string, error)
- func (s *SQLiteStore) Retrieve(key string) (any, error)
- func (s *SQLiteStore) Store(key string, value any, opts ...agents.StoreOption) error
- type StoreOption
- type StoreOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetMemoryStore ¶
GetMemoryStore retrieves the memory store from the context
func WithMemoryStore ¶
WithMemoryStore adds a memory store to the context
func WithRedisStore ¶
func WithRedisStore(ctx context.Context, store *RedisStore) context.Context
WithRedisStore adds a Redis memory store to the context This is an alias for WithMemoryStore for clarity when using Redis specifically
Types ¶
type Memory ¶
type Memory interface { // Store saves a value with the specified key. // Optional StoreOption parameters can be provided to configure the storage behavior, // such as TTL (time-to-live). Store(key string, value any, opts ...agents.StoreOption) error // Retrieve gets a value by its key. Retrieve(key string) (any, error) // List returns all keys in the store. List() ([]string, error) // Clear removes all values from the store. Clear() error // CleanExpired removes all expired entries from the store. CleanExpired(ctx context.Context) (int64, error) // Close releases resources used by the memory store. Close() error }
Memory defines the interface for key-value storage backends.
type RedisStore ¶
type RedisStore struct {
// contains filtered or unexported fields
}
RedisStore implements the Memory interface using Redis as the backend.
func GetRedisStore ¶
func GetRedisStore(ctx context.Context) (*RedisStore, error)
GetRedisStore retrieves the Redis memory store from the context
func NewRedisStore ¶
func NewRedisStore(addr, password string, db int) (*RedisStore, error)
NewRedisStore creates a new Redis-backed memory store.
func (*RedisStore) CleanExpired ¶
func (r *RedisStore) CleanExpired(ctx context.Context) (int64, error)
CleanExpired implements the Memory interface CleanExpired method. Note: Redis automatically removes expired keys, so this is a no-op.
func (*RedisStore) Clear ¶
func (r *RedisStore) Clear() error
Clear implements the Memory interface Clear method.
func (*RedisStore) Close ¶
func (r *RedisStore) Close() error
Close implements the Memory interface Close method.
func (*RedisStore) List ¶
func (r *RedisStore) List() ([]string, error)
List implements the Memory interface List method.
func (*RedisStore) Retrieve ¶
func (r *RedisStore) Retrieve(key string) (any, error)
Retrieve implements the Memory interface Retrieve method.
func (*RedisStore) Store ¶
func (r *RedisStore) Store(key string, value any, opts ...agents.StoreOption) error
Store implements the Memory interface Store method.
func (*RedisStore) StoreWithTTL ¶
func (r *RedisStore) StoreWithTTL(ctx context.Context, key string, value any, ttl time.Duration) error
StoreWithTTL implements the Memory interface StoreWithTTL method.
type SQLiteStore ¶
type SQLiteStore struct {
// contains filtered or unexported fields
}
SQLiteStore implements the Memory interface using SQLite as the backend.
func NewSQLiteStore ¶
func NewSQLiteStore(path string) (*SQLiteStore, error)
NewSQLiteStore creates a new SQLite-backed memory store. The path parameter specifies the database file location. If path is ":memory:", the database will be created in-memory.
func (*SQLiteStore) CleanExpired ¶
func (s *SQLiteStore) CleanExpired(ctx context.Context) (int64, error)
CleanExpired removes all expired entries from the store.
func (*SQLiteStore) Clear ¶
func (s *SQLiteStore) Clear() error
Clear implements the Memory interface Clear method.
func (*SQLiteStore) Close ¶
func (s *SQLiteStore) Close() error
Close closes the database connection.
func (*SQLiteStore) List ¶
func (s *SQLiteStore) List() ([]string, error)
List implements the Memory interface List method.
func (*SQLiteStore) Retrieve ¶
func (s *SQLiteStore) Retrieve(key string) (any, error)
Retrieve implements the Memory interface Retrieve method.
func (*SQLiteStore) Store ¶
func (s *SQLiteStore) Store(key string, value any, opts ...agents.StoreOption) error
Store implements the Memory interface Store method.
type StoreOption ¶
type StoreOption func(*StoreOptions)
StoreOption defines options for Store operations
func WithTTL ¶
func WithTTL(ttl time.Duration) StoreOption
WithTTL creates an option to set a TTL for a stored value
type StoreOptions ¶
StoreOptions contains configuration for Store operations