-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: fixing tests on redis server (#1)
- Loading branch information
1 parent
cbdb398
commit d5a1795
Showing
12 changed files
with
119 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,25 @@ | ||
package cache | ||
|
||
import ( | ||
"context" | ||
"time" | ||
) | ||
|
||
func GetPasswordThrottleCache(ctx context.Context, key string) (string, error) { | ||
value, err := rdb.Get(ctx, key).Result() | ||
func (r *RedisCache) GetPasswordThrottleCache(key string) (string, error) { | ||
value, err := r.client.Get(ctx, key).Result() | ||
|
||
return value, err | ||
} | ||
|
||
func SetPasswordThrottleCache(ctx context.Context, key string, duration time.Duration) error { | ||
_, err := rdb.Set(ctx, key, 1, duration).Result() | ||
func (r *RedisCache) SetPasswordThrottleCache(key string, duration time.Duration) error { | ||
_, err := r.client.Set(ctx, key, 1, duration).Result() | ||
|
||
return err | ||
} | ||
|
||
func RemovePasswordThrottleCache(ctx context.Context, email string) error { | ||
func (r *RedisCache) RemovePasswordThrottleCache(email string) error { | ||
key := "password-reset:" + email | ||
|
||
_, err := rdb.Del(ctx, key).Result() | ||
_, err := r.client.Del(ctx, key).Result() | ||
|
||
return err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
package cache | ||
|
||
import ( | ||
"context" | ||
"time" | ||
) | ||
|
||
func AddThrottleCache(ctx context.Context, key string) (count int64, error error) { | ||
count, err := rdb.Incr(ctx, key).Result() | ||
func (r *RedisCache) AddThrottleCache(key string) (count int64, error error) { | ||
count, err := r.client.Incr(ctx, key).Result() | ||
|
||
return count, err | ||
} | ||
|
||
func ExpireThrottleCache(ctx context.Context, key string, timeWindow time.Duration) { | ||
rdb.Expire(ctx, key, timeWindow) | ||
func (r *RedisCache) ExpireThrottleCache(key string, timeWindow time.Duration) { | ||
r.client.Expire(ctx, key, timeWindow) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.