You've already forked top-wallpaper
Refactor caching logic and add support for a new feature
This commit is contained in:
@@ -16,6 +16,7 @@ type contextKey string
|
||||
const redisKey contextKey = "redisClient"
|
||||
|
||||
const CacheKey = "top-wallpaper:latestImage"
|
||||
const NsfwCacheKey = "top-wallpaper-nsfw:latestImage"
|
||||
|
||||
type Cache interface {
|
||||
Get(key string) (string, error)
|
||||
@@ -92,6 +93,14 @@ func (r *Redis) Set(key string, value string, expiration time.Duration) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (*Redis) GetCacheKey(nsfw bool) string {
|
||||
if nsfw {
|
||||
return NsfwCacheKey
|
||||
}
|
||||
|
||||
return CacheKey
|
||||
}
|
||||
|
||||
func (r *Redis) Close() error {
|
||||
if r.client == nil {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user