...

Source file src/github.com/peterbourgon/diskv/examples/super-simple-store/super-simple-store.go

Documentation: github.com/peterbourgon/diskv/examples/super-simple-store

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/peterbourgon/diskv"
     7  )
     8  
     9  func main() {
    10  	d := diskv.New(diskv.Options{
    11  		BasePath:     "my-diskv-data-directory",
    12  		Transform:    func(s string) []string { return []string{} },
    13  		CacheSizeMax: 1024 * 1024, // 1MB
    14  	})
    15  
    16  	key := "alpha"
    17  	if err := d.Write(key, []byte{'1', '2', '3'}); err != nil {
    18  		panic(err)
    19  	}
    20  
    21  	value, err := d.Read(key)
    22  	if err != nil {
    23  		panic(err)
    24  	}
    25  	fmt.Printf("%v\n", value)
    26  
    27  	if err := d.Erase(key); err != nil {
    28  		panic(err)
    29  	}
    30  }
    31  

View as plain text