Skip to content

Commit

Permalink
Fix Redis key handling in Set method for URL storage
Browse files Browse the repository at this point in the history
  • Loading branch information
SartajBhuvaji committed Nov 22, 2024
1 parent 9c2aebd commit 1f8248f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions database/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,18 @@ func (r *RedisClient) GetCounter() (int, error) {
func (r *RedisClient) Set(originalURL, shortURL string) error {

value := URLValue{
URL: shortURL,
URL: originalURL,
createdAt: time.Now().String(),
lastAccessed: time.Now().String(),
AccessCount: 1,
}

err := r.client.Set(r.ctx, originalURL, value, 0).Err()
err := r.client.Set(r.ctx, shortURL, value, 0).Err()
if err != nil {
fmt.Printf("Unable to add new key '%s' to Redis: %v\n", originalURL, err)
fmt.Printf("Unable to add new key '%s' to Redis: %v\n", shortURL, err)
return err
}
fmt.Printf("Key '%s' set successfully!\n", originalURL)
fmt.Printf("Key '%s' set successfully!\n", shortURL)
return nil
}

Expand Down

0 comments on commit 1f8248f

Please sign in to comment.