memory

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LRUCache

type LRUCache[K comparable, V any] struct {
	// contains filtered or unexported fields
}

LRUCache LRU 缓存

func NewLRUCache

func NewLRUCache[K comparable, V any](capacity int) *LRUCache[K, V]

NewLRUCache 创建 LRU 缓存

func (*LRUCache[K, V]) Capacity

func (c *LRUCache[K, V]) Capacity() int

Capacity 返回缓存容量

func (*LRUCache[K, V]) Clear

func (c *LRUCache[K, V]) Clear()

Clear 清空缓存

func (*LRUCache[K, V]) Delete

func (c *LRUCache[K, V]) Delete(key K)

Delete 删除缓存项

func (*LRUCache[K, V]) Get

func (c *LRUCache[K, V]) Get(key K) (V, bool)

Get 获取缓存项

func (*LRUCache[K, V]) Put

func (c *LRUCache[K, V]) Put(key K, value V)

Put 放入缓存项

func (*LRUCache[K, V]) Size

func (c *LRUCache[K, V]) Size() int

Size 返回缓存大小

type MemoryStorage

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

MemoryStorage 内存存储引擎

func NewMemoryStorage

func NewMemoryStorage() *MemoryStorage

NewMemoryStorage 创建内存存储

func (*MemoryStorage) BatchDelete

func (s *MemoryStorage) BatchDelete(ids []string) error

BatchDelete 批量删除向量

func (*MemoryStorage) BatchGet

func (s *MemoryStorage) BatchGet(ids []string) ([]*types.Vector, error)

BatchGet 批量获取向量

func (*MemoryStorage) BatchPut

func (s *MemoryStorage) BatchPut(vectors []*types.Vector) error

BatchPut 批量存储向量

func (*MemoryStorage) Close

func (s *MemoryStorage) Close() error

Close 关闭存储

func (*MemoryStorage) Count

func (s *MemoryStorage) Count() (int, error)

Count 获取向量数量

func (*MemoryStorage) Delete

func (s *MemoryStorage) Delete(id string) error

Delete 删除单个向量

func (*MemoryStorage) Get

func (s *MemoryStorage) Get(id string) (*types.Vector, error)

Get 获取单个向量

func (*MemoryStorage) Iterate

func (s *MemoryStorage) Iterate(fn func(*types.Vector) bool) error

Iterate 迭代所有向量

func (*MemoryStorage) Load

func (s *MemoryStorage) Load(path string) error

Load 从文件加载

func (*MemoryStorage) Put

func (s *MemoryStorage) Put(vec *types.Vector) error

Put 存储单个向量

func (*MemoryStorage) Save

func (s *MemoryStorage) Save(path string) error

Save 保存到文件

Jump to

Keyboard shortcuts

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