From 04b99d5e3022cea0da76bed06f6e05e8aa193ed1 Mon Sep 17 00:00:00 2001 From: kpango Date: Sat, 16 Feb 2019 22:39:06 +0900 Subject: [PATCH] fix --- example/main.go | 9 +++++++++ gache.go | 2 +- go.mod | 4 ++-- go.sum | 9 ++++----- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/example/main.go b/example/main.go index 82ef38e..7bbe6da 100644 --- a/example/main.go +++ b/example/main.go @@ -1,6 +1,7 @@ package main import ( + "context" "time" "github.com/kpango/gache" @@ -56,4 +57,12 @@ func main() { if ok { glg.Info(v6) } + + gc.Write(context.Background(), glg.FileWriter("./gache-sample.gdb", 0755)) + gcn := gache.New().SetDefaultExpire(time.Minute) + gcn.Read(glg.FileWriter("./gache-sample.gdb", 0755)) + gache.Foreach(context.Background(), func(k string, v interface{}, exp int64) bool { + glg.Debugf("key:\t%v\nval:\t%v", k, v) + return true + }) } diff --git a/gache.go b/gache.go index fca6a03..8a50e6e 100644 --- a/gache.go +++ b/gache.go @@ -11,7 +11,7 @@ import ( "github.com/cespare/xxhash/v2" "github.com/kpango/fastime" - "github.com/pierrec/lz4/v2" + "github.com/pierrec/lz4" "golang.org/x/sync/singleflight" ) diff --git a/go.mod b/go.mod index d1cbe3b..961834e 100644 --- a/go.mod +++ b/go.mod @@ -6,11 +6,11 @@ require ( github.com/bluele/gcache v0.0.0-20190203144525-2016d595ccb0 github.com/cespare/xxhash/v2 v2.0.0 github.com/coocood/freecache v1.0.1 - github.com/hlts2/gocache v0.0.0-20190216063039-f2b89fd577c0 + github.com/hlts2/gocache v0.0.0-20190216130302-fca39ad0fd30 github.com/kpango/fastime v1.0.2 github.com/kpango/glg v1.2.7 github.com/patrickmn/go-cache v2.1.0+incompatible - github.com/pierrec/lz4/v2 v2.0.8 + github.com/pierrec/lz4 v2.0.5+incompatible golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 google.golang.org/appengine v1.4.0 // indirect ) diff --git a/go.sum b/go.sum index 8cdb9df..49b48cd 100644 --- a/go.sum +++ b/go.sum @@ -18,8 +18,8 @@ github.com/coocood/freecache v1.0.1/go.mod h1:ePwxCDzOYvARfHdr1pByNct1at3CoKnsip github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/hlts2/gocache v0.0.0-20181007125314-e9a99e525ba1/go.mod h1:u/v6wO8kS57bViN/degQAjOX3zGWVx3VW2HOClP2Vcc= -github.com/hlts2/gocache v0.0.0-20190216063039-f2b89fd577c0 h1:NOZ1f8hBpM5aR/jhvH0yLw7ADsiK45HUu3qhjteYfEM= -github.com/hlts2/gocache v0.0.0-20190216063039-f2b89fd577c0/go.mod h1:F4tUovaw56AzbV8K7ET39ZhQLFP8c8bLXRIuVvHAHUg= +github.com/hlts2/gocache v0.0.0-20190216130302-fca39ad0fd30 h1:dUuT9Ybk/6gg0I03Z0ET5jXFvloA0VXr6DG2xt3He24= +github.com/hlts2/gocache v0.0.0-20190216130302-fca39ad0fd30/go.mod h1:F4tUovaw56AzbV8K7ET39ZhQLFP8c8bLXRIuVvHAHUg= github.com/kpango/fastime v1.0.0/go.mod h1:Y5XY5bLG5yc7g2XmMUzc22XYV1XaH+KgUOHkDvLp4SA= github.com/kpango/fastime v1.0.2 h1:yBowxbDW0qz6EcmoV6ASj4aprgmpzDIlsd+ECN2RiaU= github.com/kpango/fastime v1.0.2/go.mod h1:Y5XY5bLG5yc7g2XmMUzc22XYV1XaH+KgUOHkDvLp4SA= @@ -28,9 +28,8 @@ github.com/kpango/glg v1.2.7 h1:aVnv89IIWXSFNOm93SnDQGIKF27Jzz9olieOL2b23Xc= github.com/kpango/glg v1.2.7/go.mod h1:sEwy6Va116x0eKdbVsilHPanIrsoE9AR/9vHwdo4ytQ= github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc= github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ= -github.com/pierrec/lz4 v0.0.0-20190131084431-473cd7ce01a1 h1:0utzB5Mn6QyMzIeOn+oD7pjKQLjJwfM9bz6TkPPdxcw= -github.com/pierrec/lz4 v0.0.0-20190131084431-473cd7ce01a1/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc= -github.com/pkg/profile v1.2.1/go.mod h1:hJw3o1OdXxsrSjjVksARp5W95eeEaEfptyVZyv6JUPA= +github.com/pierrec/lz4 v2.0.5+incompatible h1:2xWsjqPFWcplujydGg4WmhC/6fZqK42wMM8aXeqhl0I= +github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi+IEE17M5jbnwPHcY= github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= github.com/vmihailenco/msgpack v4.0.1+incompatible h1:RMF1enSPeKTlXrXdOcqjFUElywVZjjC6pqse21bKbEU= github.com/vmihailenco/msgpack v4.0.1+incompatible/go.mod h1:fy3FlTQTDXWkZ7Bh6AcGMlsjHatGryHQYUTf1ShIgkk=