Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommonIndex ¶
type CommonIndex[T comparable] struct { // contains filtered or unexported fields }
CommonIndex is a common implementation of Index. It is thread-safe. It is used by Bucket to provide indexes for its items. It supports the following operations:
- Get(T) ([]int, error)
- Set(T, int) error
- Remove(T, int) error
- Delete(key) error
- Clear()
- Exists(T) bool
func NewCommonIndex ¶
func NewCommonIndex[T comparable]() *CommonIndex[T]
NewCommonIndex creates a new CommonIndex.
func (*CommonIndex[T]) Delete ¶
func (i *CommonIndex[T]) Delete(id int)
Delete deletes the item with the given ID.
type Indexer ¶
Indexer is an index resolver. It is used to resolve a list of IDs that match a list of keys. It uses a map to store indexes by string keys. It is thread-safe. It is used by the Bucket to resolve the IDs of the objects that match a list of keys. It supports both unique and common indexes. It follows the builder pattern. It supports the following operations: - Set(int, map[string]interface{}): sets the IDs of the objects that match the given keys. - Resolve(...key): resolves the IDs of the objects that match the given keys. - Unset(id): removes the given ID from the indexes. - WithIndex(name, index): adds the given index to the indexer. - Clear(): clears the indexer.
func (*Indexer) Resolve ¶
Resolve resolves the IDs of the objects that match the given keys. It returns an error if any of the indexes returns an error.
func (*Indexer) Set ¶
Set sets the IDs of the objects that match the given keys. It returns an error if any of the indexes returns an error.
type Indices ¶
type Indices map[string]interface{}
Indices is a map of index names to interfaces. It is used to provide indexes for an item when it is added to a bucket.
type UniqueIndex ¶
type UniqueIndex[T comparable] struct { // contains filtered or unexported fields }
UniqueIndex is a unique index. It implements the Index interface. It is thread-safe. It is used by Bucket to provide indexes for its items. It supports the following operations:
- Get(T) ([]int, error)
- Set(T, int) error
- Delete(int) error
- Clear()
func NewUniqueIndex ¶
func NewUniqueIndex[T comparable]() *UniqueIndex[T]
NewUniqueIndex creates a new UniqueIndex.
func (*UniqueIndex[T]) Delete ¶
func (i *UniqueIndex[T]) Delete(id int)
Delete deletes the item with the given ID from the index.