Skip to content

Commit

Permalink
feat: update redis and urllib for v2
Browse files Browse the repository at this point in the history
  • Loading branch information
dapeng committed Dec 17, 2024
1 parent 70d848d commit e5b2aa9
Show file tree
Hide file tree
Showing 22 changed files with 262 additions and 386 deletions.
1 change: 1 addition & 0 deletions error.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,5 @@ const (
LoadedError = 1007
FailInstall = 1008
InjectError = 1009
ProviderError = 1010
)
15 changes: 7 additions & 8 deletions goner/redis/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,18 @@ import (
"errors"
"fmt"
"github.com/gomodule/redigo/redis"
"github.com/gone-io/gone"
"github.com/gone-io/gone/internal/json"
"strings"
"time"
)

func NewRedisCache() (gone.Goner, gone.GonerId, gone.GonerOption) {
return &cache{}, gone.IdGoneRedisCache, gone.IsDefault(new(Cache))
}

func NewRedisKey() (gone.Goner, gone.GonerId, gone.GonerOption) {
return &cache{}, gone.IdGoneRedisKey, gone.IsDefault(new(Key))
}
//func NewRedisCache() (gone.Goner, gone.GonerId, gone.GonerOption) {
// return &cache{}, gone.IdGoneRedisCache, gone.IsDefault(new(Cache))
//}
//
//func NewRedisKey() (gone.Goner, gone.GonerId, gone.GonerOption) {
// return &cache{}, gone.IdGoneRedisKey, gone.IsDefault(new(Key))
//}

type cache struct {
*inner `gone:"gone-redis-inner"`
Expand Down
71 changes: 0 additions & 71 deletions goner/redis/cache_provider.go

This file was deleted.

121 changes: 0 additions & 121 deletions goner/redis/cache_provider_test.go

This file was deleted.

17 changes: 8 additions & 9 deletions goner/redis/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

func TestCache(t *testing.T) {
gone.Test(func(c *cache) {
gone.Loads(Load).Test(func(c *cache) {
type Point struct {
X int
Y int
Expand Down Expand Up @@ -46,11 +46,11 @@ func TestCache(t *testing.T) {
<-time.After(ttl + 2*time.Second)
err = c.Get(key, value2)
assert.Equal(t, ErrNil, err)
}, Priest)
})
}

func Test_cache_Keys(t *testing.T) {
gone.Test(func(c *cache) {
gone.Loads(Load).Test(func(c *cache) {
n := 10
f := rand.Intn(100)

Expand Down Expand Up @@ -79,7 +79,7 @@ func Test_cache_Keys(t *testing.T) {
err := c.Remove(k)
assert.Nil(t, err)
}
}, Priest)
})
}

type useKey struct {
Expand All @@ -89,7 +89,9 @@ type useKey struct {
}

func TestKey(t *testing.T) {
gone.Test(func(u *useKey) {
gone.Loads(Load, func(loader gone.Loader) error {
return loader.Load(&useKey{})
}).Test(func(u *useKey) {
assert.Equal(t, u.key, u.cache)
key := "test-key"
value := "10"
Expand Down Expand Up @@ -124,8 +126,5 @@ func TestKey(t *testing.T) {
err = u.key.Del(key2)
assert.Nil(t, err)

}, func(cemetery gone.Cemetery) error {
cemetery.Bury(&useKey{})
return nil
}, Priest)
})
}
Loading

0 comments on commit e5b2aa9

Please sign in to comment.