Documentation ¶
Index ¶
- Constants
- Variables
- type BadgerStore
- func (s *BadgerStore) Add(updates map[string]ItemInfo) (err error)
- func (s *BadgerStore) Close() (err error)
- func (s *BadgerStore) Delete(key string) (err error)
- func (s *BadgerStore) Find(key string) (item ItemInfo)
- func (s *BadgerStore) Info() string
- func (s *BadgerStore) Items() (items []*ItemInfo, err error)
- func (s *BadgerStore) Keys(prefix string, pattern string, limit int) (keys []string)
- func (s *BadgerStore) Maintenance()
- func (s *BadgerStore) Open() (err error)
- func (s *BadgerStore) Reset() (err error)
- func (s *BadgerStore) Type() DatabaseType
- type DatabaseType
- type ItemInfo
- type ItemType
- type Store
Constants ¶
const BatchCount int = 100
BatchCount specifies the batch count for store operations.
Variables ¶
var ( ErrOpenStore = errors.New("open store error") ErrCloseStore = errors.New("close store error") )
Errors related to store operations.
Functions ¶
This section is empty.
Types ¶
type BadgerStore ¶
type BadgerStore struct {
// contains filtered or unexported fields
}
BadgerStore is an implementation of the Store interface using the Badger database.
func (*BadgerStore) Add ¶
func (s *BadgerStore) Add(updates map[string]ItemInfo) (err error)
Add adds or updates items in the Badger store. If the transaction becomes too big, it is committed, and a new transaction is started.
func (*BadgerStore) Close ¶
func (s *BadgerStore) Close() (err error)
Close closes the Badger store.
func (*BadgerStore) Delete ¶
func (s *BadgerStore) Delete(key string) (err error)
Delete deletes an item from the Badger store based on the key.
func (*BadgerStore) Find ¶
func (s *BadgerStore) Find(key string) (item ItemInfo)
Find retrieves information about an item from the Badger store based on the key.
func (*BadgerStore) Info ¶
func (s *BadgerStore) Info() string
Info returns information about the Badger store, including whether it's in-memory and the store path.
func (*BadgerStore) Items ¶
func (s *BadgerStore) Items() (items []*ItemInfo, err error)
Items retrieves all items from the Badger store.
func (*BadgerStore) Keys ¶
func (s *BadgerStore) Keys(prefix string, pattern string, limit int) (keys []string)
Keys retrieves keys from the Badger store based on the prefix, pattern, and limit.
func (*BadgerStore) Maintenance ¶
func (s *BadgerStore) Maintenance()
Maintenance performs maintenance tasks on the Badger store, such as value log garbage collection.
func (*BadgerStore) Reset ¶
func (s *BadgerStore) Reset() (err error)
Reset resets the Badger store, dropping all data. TODO: Need mutex for read and writes
func (*BadgerStore) Type ¶
func (s *BadgerStore) Type() DatabaseType
Type returns the type of the database (Badger in this case).
type DatabaseType ¶
type DatabaseType string
DatabaseType represents the type of the database.
const BadgerDatabaseType DatabaseType = "badger"
BadgerDatabaseType represents the Badger database type.
type ItemInfo ¶
type ItemInfo struct { Name string // Name of the item. Path string // Path to the item. Type ItemType // Type of the item. MimeType string // MIME type of the item. ModTime time.Time // Modification time of the item. Size int64 // Size of the item. Hash string // Hash of the item. }
ItemInfo represents information about an item in the store.
func NewItemInfo ¶
NewItemInfo creates a new ItemInfo with the specified attributes.
type Store ¶
type Store interface { Open() error // Open the store. Close() error // Close the store. Reset() error // Reset the store. Delete(key string) error // Delete a key from the store. Find(key string) ItemInfo // Find information about a key in the store. Info() string // Get information about the store. Maintenance() // Perform maintenance tasks on the store. Type() DatabaseType // Get the type of the database. Keys(prefix string, pattern string, limit int) []string // Get keys based on prefix, pattern, and limit. Add(map[string]ItemInfo) error // Add items to the store. Items() ([]*ItemInfo, error) // Get all items from the store. // DEBUG func }
Store defines the interface for a key-value store.
func NewBadgerStore ¶
NewBadgerStore creates a new BadgerStore instance based on the provided parameters.
func NewDiskBadgerStore ¶
NewDiskBadgerStore creates a new BadgerStore instance for disk-based storage.
func NewInMemoryBadgerStore ¶
func NewInMemoryBadgerStore() Store
NewInMemoryBadgerStore creates a new BadgerStore instance for in-memory storage.