...

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

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

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

View as plain text