You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
666 B

  1. package metastore
  2. import (
  3. "io/ioutil"
  4. "os"
  5. )
  6. // store data on disk, enough for most cases
  7. type MetaStoreFileBacking struct {
  8. }
  9. func NewMetaStoreFileBacking() *MetaStoreFileBacking {
  10. mms := &MetaStoreFileBacking{}
  11. return mms
  12. }
  13. func (mms *MetaStoreFileBacking) Set(path, val string) error {
  14. return ioutil.WriteFile(path, []byte(val), 0644)
  15. }
  16. func (mms *MetaStoreFileBacking) Get(path string) (string, error) {
  17. val, e := ioutil.ReadFile(path)
  18. return string(val), e
  19. }
  20. func (mms *MetaStoreFileBacking) Has(path string) (ok bool) {
  21. seqFile, se := os.OpenFile(path, os.O_RDONLY, 0644)
  22. if se != nil {
  23. return false
  24. }
  25. defer seqFile.Close()
  26. return true
  27. }