Skip to content

Commit

Permalink
default value is singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
linyows committed May 31, 2018
1 parent 9eba8f4 commit eb28303
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions kvs/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ import (
"sync"
)

var (
DefaultTempDir string = createTempDir()
DefaultMaxSize int64 = 64 * 1024 * 1024
)

func createTempDir() string {
dir, _ := ioutil.TempDir("", "dewy-")
return dir
}

type File struct {
items map[string]*item
dir string
Expand All @@ -23,16 +33,9 @@ func (f *File) GetDir() string {
return f.dir
}

func (f *File) Default() error {
dir, err := ioutil.TempDir("", "dewy")
if err != nil {
return err
}

f.dir = dir
f.MaxSize = 64 * 1024 * 1024

return nil
func (f *File) Default() {
f.dir = DefaultTempDir
f.MaxSize = DefaultMaxSize
}

func (f *File) Read(key string) ([]byte, error) {
Expand Down

0 comments on commit eb28303

Please sign in to comment.