Documentation ¶
Overview ¶
Package store abstracts the persistent storage used by elvish.
Index ¶
- Constants
- Variables
- func DefaultDB(dbname string) (*bolt.DB, error)
- func SchemaUpToDate(db *bolt.DB) bool
- type Store
- func (s *Store) AddCmd(cmd string) (int, error)
- func (s *Store) AddDir(d string, incFactor float64) error
- func (s *Store) AddDirRaw(d string, score float64) error
- func (s *Store) Close() error
- func (s *Store) Cmd(seq int) (string, error)
- func (s *Store) Cmds(from, upto int) ([]string, error)
- func (s *Store) DelSharedVar(n string) error
- func (s *Store) GetDirs(blacklist map[string]struct{}) ([]storedefs.Dir, error)
- func (s *Store) GetSharedVar(n string) (string, error)
- func (s *Store) IterateCmds(from, upto int, f func(string) bool) error
- func (s *Store) NextCmd(from int, prefix string) (int, string, error)
- func (s *Store) NextCmdSeq() (int, error)
- func (s *Store) PrevCmd(upto int, prefix string) (int, string, error)
- func (s *Store) RemoveCmd(seq int) error
- func (s *Store) RemoveDir(d string) error
- func (s *Store) SetSharedVar(n, v string) error
- func (s *Store) Waits() *sync.WaitGroup
Constants ¶
const BucketCmd = "cmd"
const BucketDir = "dir"
const BucketSchema = "schema"
const SchemaVersion = 1
SchemaVersion is the current schema version. It should be bumped every time a backwards-incompatible change has been made to the schema.
Variables ¶
var ErrInvalidBucket = errors.New("invalid bucket")
var ErrNoVar = errors.New("no such variable")
ErrNoVar is returned by (*Store).GetSharedVar when there is no such variable.
Functions ¶
func SchemaUpToDate ¶ added in v0.5.0
SchemaUpToDate returns whether the database has the current or newer version of the schema.
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the permanent storage backend for elvish. It is not thread-safe. In particular, the store may be closed while another goroutine is still accessing the store. To prevent bad things from happening, every time the main goroutine spawns a new goroutine to operate on the store, it should call Waits.Add(1) in the main goroutine before spawning another goroutine, and call Waits.Done() in the spawned goroutine after the operation is finished.
func NewStoreDB ¶
NewStoreDB creates a new Store with a custom database. The database must be a Bolt database.
func (*Store) Close ¶
Close waits for all outstanding operations to finish, and closes the database.
func (*Store) DelSharedVar ¶
DelSharedVar deletes a shared variable.
func (*Store) GetDirs ¶ added in v0.8.0
GetDirs lists all directories in the directory history whose names are not in the blacklist. The results are ordered by scores in descending order.
func (*Store) GetSharedVar ¶
GetSharedVar gets the value of a shared variable.
func (*Store) IterateCmds ¶ added in v0.5.0
IterateCmds iterates all the commands in the specified range, and calls the callback with the content of each command sequentially.
func (*Store) NextCmd ¶ added in v0.9.0
NextCmd finds the first command after the given sequence number (inclusive) with the given prefix.
func (*Store) NextCmdSeq ¶
NextCmdSeq returns the next sequence number of the command history.
func (*Store) PrevCmd ¶ added in v0.9.0
PrevCmd finds the last command before the given sequence number (exclusive) with the given prefix.
func (*Store) RemoveCmd ¶ added in v0.10.0
RemoveCmd removes a command from command history referenced by sequence.
func (*Store) SetSharedVar ¶
SetSharedVar sets the value of a shared variable.