Skip to content
/ gobcache Public

Save data to disk as *.gob files and reuse them later

Notifications You must be signed in to change notification settings

ilk/gobcache

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gobcache

License: MIT GoDoc

gobcache is a simple way to store data temporarily.

Main usage is for development where you have to deal with data which takes long to fetch.

Example usage

  import (
    "fmt"

    "github.com/ilk/gobcache"
  )

  func main() {
    cache := gobcache.NewCache(gobcache.Config{})
    data := ""
    exampleData := `{"data":"I'm a huge json'"}`

    // get data from cache if exists
    if err := cache.GetData("123", &data); err != nil {
      // instead of assign exampleData, fetch your "fetch" function or whatever
      data = exampleData

      if err := cache.SaveData("123", data); err != nil {
        // handle error
        fmt.Printf("ooops %v\n", err)
      }
    }
    //
    fmt.Println(data)
  }

About

Save data to disk as *.gob files and reuse them later

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages