24 lines
438 B
Go
24 lines
438 B
Go
package redis
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
|
|
"github.com/redis/go-redis/v9"
|
|
)
|
|
|
|
func Get(ctx context.Context, key string) (string, error) {
|
|
str, err := client.Get(ctx, key).Result()
|
|
if err == redis.Nil {
|
|
return "", nil
|
|
} else if err != nil {
|
|
return "", err
|
|
}
|
|
|
|
return str, nil
|
|
}
|
|
|
|
func Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error {
|
|
return client.Set(ctx, key, value, expiration).Err()
|
|
}
|