Skip to content

Commit cf90570

Browse files
committed
Merge branch 'master' of https://gopkg.in/go-oauth2/redis.v3
2 parents ab8d028 + b02ea38 commit cf90570

File tree

4 files changed

+14
-170
lines changed

4 files changed

+14
-170
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,22 @@ $ go get -u -v gopkg.in/go-oauth2/redis.v3
1414
package main
1515

1616
import (
17-
"gopkg.in/go-oauth2/redis.v3"
17+
"github.com/go-redis/redis"
18+
oredis "gopkg.in/go-oauth2/redis.v3"
1819
"gopkg.in/oauth2.v3/manage"
1920
)
2021

2122
func main() {
2223
manager := manage.NewDefaultManager()
2324

2425
// use redis token store
25-
manager.MapTokenStorage(redis.NewRedisStore(&redis.Options{
26+
manager.MapTokenStorage(oredis.NewRedisStore(&redis.Options{
2627
Addr: "127.0.0.1:6379",
2728
DB: 15,
2829
}))
2930

3031
// use redis cluster store
31-
// manager.MapTokenStorage(redis.NewRedisClusterStore(&redis.ClusterOptions{
32+
// manager.MapTokenStorage(oredis.NewRedisClusterStore(&redis.ClusterOptions{
3233
// Addrs: []string{"127.0.0.1:6379"},
3334
// DB: 15,
3435
// }))

options.go

-157
This file was deleted.

redis.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ var (
1818
)
1919

2020
// NewRedisStore create an instance of a redis store
21-
func NewRedisStore(opts *Options) *TokenStore {
21+
func NewRedisStore(opts *redis.Options, keyNamespace ...string) *TokenStore {
2222
if opts == nil {
2323
panic("options cannot be nil")
2424
}
25-
return NewRedisStoreWithCli(redis.NewClient(opts.redisOptions()), opts.KeyNamespace)
25+
return NewRedisStoreWithCli(redis.NewClient(opts), keyNamespace...)
2626
}
2727

2828
// NewRedisStoreWithCli create an instance of a redis store
@@ -38,11 +38,11 @@ func NewRedisStoreWithCli(cli *redis.Client, keyNamespace ...string) *TokenStore
3838
}
3939

4040
// NewRedisClusterStore create an instance of a redis cluster store
41-
func NewRedisClusterStore(opts *ClusterOptions) *TokenStore {
41+
func NewRedisClusterStore(opts *redis.ClusterOptions, keyNamespace ...string) *TokenStore {
4242
if opts == nil {
4343
panic("options cannot be nil")
4444
}
45-
return NewRedisClusterStoreWithCli(redis.NewClusterClient(opts.redisClusterOptions()), opts.KeyNamespace)
45+
return NewRedisClusterStoreWithCli(redis.NewClusterClient(opts), keyNamespace...)
4646
}
4747

4848
// NewRedisClusterStoreWithCli create an instance of a redis cluster store

redis_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"testing"
55
"time"
66

7+
"github.com/go-redis/redis"
78
"gopkg.in/oauth2.v3/models"
89

910
. "github.com/smartystreets/goconvey/convey"
@@ -16,7 +17,7 @@ const (
1617

1718
func TestTokenStore(t *testing.T) {
1819
Convey("Test redis token store", t, func() {
19-
opts := &Options{
20+
opts := &redis.Options{
2021
Addr: addr,
2122
DB: db,
2223
}
@@ -104,12 +105,11 @@ func TestTokenStore(t *testing.T) {
104105

105106
func TestTokenStoreWithKeyNamespace(t *testing.T) {
106107
Convey("Test redis token store", t, func() {
107-
opts := &Options{
108-
Addr: addr,
109-
DB: db,
110-
KeyNamespace: "test:",
108+
opts := &redis.Options{
109+
Addr: addr,
110+
DB: db,
111111
}
112-
store := NewRedisStore(opts)
112+
store := NewRedisStore(opts, "test:")
113113

114114
Convey("Test authorization code store", func() {
115115
info := &models.Token{

0 commit comments

Comments
 (0)