go mini file cache
$ go get github.com/migopher/micache
package main
import "github.com/migopher/micache"
func main() {
// set cache file path cache/
micache.Dir="cache/"
}
set cache and time
package main
import "github.com/migopher/micache"
func main() {
// set key expiration time 3600s or 0 is permanent save
micache.Set("go", "golang", 3600)
}
get key cache value
package main
import (
"fmt"
"github.com/migopher/micache"
)
func main() {
// get key cache value
v := micache.Get("go")
fmt.Println(v)
}
get key cache struct value
package main
import (
"fmt"
"github.com/migopher/micache"
)
type User struct {
Uid int
UserName string
}
func main() {
getUser:=User{}
micache.GetDecoding("go", &getUser)
fmt.Println(getUser)
}
package main
import (
"fmt"
"github.com/migopher/micache"
)
func main() {
b:=micache.IsExist("go")
fmt.Println(b)
}
delete cache key
package main
import (
"fmt"
"github.com/migopher/micache"
)
func main() {
b:=micache.Delete("go")
fmt.Println(b)
}