internal/kliento/redisRepository.go   A
last analyzed

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 12
dl 0
loc 24
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A kliento.NewRedisRepository 0 2 1
A kliento.*RedisRepository.SetName 0 2 1
A kliento.*RedisRepository.GetName 0 2 1
1
package kliento
2
3
import (
4
	"context"
5
6
	"github.com/redis/go-redis/v9"
7
)
8
9
type RedisRepository struct {
10
	RedisConn *redis.Client
11
}
12
13
func NewRedisRepository(redisConn *redis.Client) IRedisRepository {
14
	return &RedisRepository{RedisConn: redisConn}
15
}
16
17
// GetName returns the name of the repository.
18
func (r *RedisRepository) GetName() string {
19
	return r.RedisConn.Get(context.Background(), "name").Val()
20
}
21
22
// SetName sets the name of the repository.
23
func (r *RedisRepository) SetName(name string) error {
24
	return r.RedisConn.Set(context.Background(), "name", name, 0).Err()
25
}
26