github.com/ars0915/glossika-exercise@v0.0.0-20240904180321-a5617a00d892/repo/rediscluster/cache.go (about)

     1  package rediscluster
     2  
     3  import (
     4  	"context"
     5  	"time"
     6  
     7  	"github.com/pkg/errors"
     8  )
     9  
    10  func (r RedisRepo) Set(ctx context.Context, key string, value interface{}, expiration time.Duration) error {
    11  	if err := r.client.Set(ctx, key, value, expiration).Err(); err != nil {
    12  		return errors.Wrap(err, "error setting value")
    13  	}
    14  	return nil
    15  }
    16  
    17  func (r RedisRepo) Get(ctx context.Context, key string) (string, error) {
    18  	return r.client.Get(ctx, key).Result()
    19  }