manager
v1.21.5
github.com/luxfi/database/manager
Documentation
pkg.go.dev ↗Functions
AvailableTypes
func AvailableTypes() []string
AvailableTypes returns a list of available database types
RegisterDatabaseType
func RegisterDatabaseType(name string, creator DatabaseCreator)
RegisterDatabaseType registers a database creator for a given type
Types
Config
type Config struct {
// Type is the database type ("badgerdb", "memdb", or optionally "leveldb", "pebbledb" if built with those tags)
Type string
// Path is the database path (relative to base directory)
Path string
// Namespace is used for metrics
Namespace string
// CacheSize is the size of the cache in MB
CacheSize int
// HandleCap is the maximum number of open file handles
HandleCap int
// EnableMetrics enables metrics
EnableMetrics bool
// EnableVersioning enables database versioning
EnableVersioning bool
// Prefix adds a prefix to all keys
Prefix []byte
// ReadOnly opens the database in read-only mode
ReadOnly bool
}
Config defines the database configuration.
DefaultBadgerDBConfig
func DefaultBadgerDBConfig(path string) *Config
DefaultBadgerDBConfig returns a default BadgerDB configuration.
DefaultMemoryConfig
func DefaultMemoryConfig() *Config
DefaultMemoryConfig returns a default in-memory database configuration.
DatabaseCreator
type DatabaseCreator func(path string, config *Config, registerer metric.Registerer) (db.Database, error)
DatabaseCreator is a function that creates a database
Manager
type Manager struct {
// contains filtered or unexported fields
}
Manager is a database manager that can create new database instances.
NewManager
func NewManager(baseDir string, registerer metric.Registerer) *Manager
NewManager creates a new database manager.
Manager.New
func (m *Manager) New(config *Config) (db.Database, error)
New creates a new database instance.