Package store defines the permanent storage service.



    View Source
    const (
    	DirScoreDecay     = 0.986 // roughly 0.5^(1/50)
    	DirScoreIncrement = 10
    	DirScorePrecision = 6

      Parameters for directory history scores.


      View Source
      var ErrNoMatchingCmd = errors.New("no matching command line")

        ErrNoMatchingCmd is the error returned when a LastCmd or FirstCmd query completes with no result.

        View Source
        var ErrNoSharedVar = errors.New("no such shared variable")

          ErrNoSharedVar is returned by Store.SharedVar when there is no such variable.

          View Source
          var NoBlacklist = map[string]struct{}{}

            NoBlacklist is an empty blacklist, to be used in GetDirs.


            This section is empty.


            type Cmd

            type Cmd struct {
            	Text string
            	Seq  int

              Cmd is an entry in the command history.

              type DBStore

              type DBStore interface {
              	Waits() *sync.WaitGroup
              	Close() error

                DBStore 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 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 MustGetTempStore

                func MustGetTempStore() (DBStore, func())

                  MustGetTempStore returns a Store backed by a temporary file, and a cleanup function that should be called when the Store is no longer used.

                  func NewStore

                  func NewStore(dbname string) (DBStore, error)

                    NewStore creates a new Store from the given file.

                    func NewStoreFromDB

                    func NewStoreFromDB(db *bolt.DB) (DBStore, error)

                      NewStoreFromDB creates a new Store from a bolt DB.

                      type Dir

                      type Dir struct {
                      	Path  string
                      	Score float64

                        Dir is an entry in the directory history.

                        type Store

                        type Store interface {
                        	NextCmdSeq() (int, error)
                        	AddCmd(text string) (int, error)
                        	DelCmd(seq int) error
                        	Cmd(seq int) (string, error)
                        	Cmds(from, upto int) ([]string, error)
                        	CmdsWithSeq(from, upto int) ([]Cmd, error)
                        	NextCmd(from int, prefix string) (Cmd, error)
                        	PrevCmd(upto int, prefix string) (Cmd, error)
                        	AddDir(dir string, incFactor float64) error
                        	DelDir(dir string) error
                        	Dirs(blacklist map[string]struct{}) ([]Dir, error)
                        	SharedVar(name string) (string, error)
                        	SetSharedVar(name, value string) error
                        	DelSharedVar(name string) error

                          Store is an interface satisfied by the storage service.


                          Path Synopsis
                          Package storetest keeps test suites against store.Store.
                          Package storetest keeps test suites against store.Store.