|
@@ -12,18 +12,16 @@ type RedisSessionStore struct {
|
12
|
12
|
}
|
13
|
13
|
|
14
|
14
|
func NewRedisSessionStore(address string, password string) *RedisSessionStore {
|
15
|
|
- session := &RedisSessionStore{once:&sync.Once{}}
|
16
|
|
- session.once.Do(func() {
|
17
|
|
- session.client = redis.NewClient(&redis.Options{
|
18
|
|
- Addr: address,
|
19
|
|
- Password: password,
|
20
|
|
- })
|
21
|
|
-
|
22
|
|
- if err := session.client.Ping().Err(); err != nil {
|
23
|
|
- panic(err)
|
24
|
|
- }
|
|
15
|
+ session := &RedisSessionStore{once: &sync.Once{}}
|
|
16
|
+ session.client = redis.NewClient(&redis.Options{
|
|
17
|
+ Addr: address,
|
|
18
|
+ Password: password,
|
25
|
19
|
})
|
26
|
20
|
|
|
21
|
+ if err := session.client.Ping().Err(); err != nil {
|
|
22
|
+ panic(err)
|
|
23
|
+ }
|
|
24
|
+
|
27
|
25
|
return session
|
28
|
26
|
}
|
29
|
27
|
|
|
@@ -32,18 +30,9 @@ func (rss *RedisSessionStore) StoreJwtToken(key string, value string, timeout ti
|
32
|
30
|
}
|
33
|
31
|
|
34
|
32
|
func (rss *RedisSessionStore) IsExistsJwtToken(key string) bool {
|
35
|
|
- if v := rss.client.Exists(key).Val(); v != 1 {
|
36
|
|
- return false
|
37
|
|
- }
|
38
|
|
-
|
39
|
|
- return true
|
|
33
|
+ return rss.client.Exists(key).Val() == 1
|
40
|
34
|
}
|
41
|
35
|
|
42
|
|
-// DeleteJwtToken delete jwt token
|
43
|
36
|
func (rss *RedisSessionStore) DeleteJwtToken(key string) bool {
|
44
|
|
- if v := rss.client.Del(key).Val(); v != 1 {
|
45
|
|
- return false
|
46
|
|
- }
|
47
|
|
-
|
48
|
|
- return true
|
|
37
|
+ return rss.client.Del(key).Val() == 1
|
49
|
38
|
}
|