Skip to content

Commit

Permalink
feat!(db/redis): remove backward compatibility code
Browse files Browse the repository at this point in the history
  • Loading branch information
MaineK00n committed Nov 5, 2024
1 parent 6920f82 commit 2abe218
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions db/redis.go
Original file line number Diff line number Diff line change
Expand Up @@ -258,18 +258,11 @@ func (r *RedisDriver) GetSimilarCpesByTitle(query string, n int, algorithm edlib
ctx := context.Background()
var ts []string
bs, err := r.conn.Get(ctx, titleListCacheKey).Bytes()
if err == nil {
if err := json.Unmarshal(bs, &ts); err != nil {
return nil, xerrors.Errorf("Failed to Unmarshal JSON. err: %w", err)
}
} else {
if !xerrors.Is(err, redis.Nil) {
return nil, xerrors.Errorf("Failed to Get Titles. err: %w", err)
}
ts, err = r.conn.SMembers(ctx, titleListKey).Result()
if err != nil {
return nil, xerrors.Errorf("Failed to SMembers Titles. err: %w", err)
}
if err != nil {
return nil, xerrors.Errorf("Failed to Get Titles. err: %w", err)
}
if err := json.Unmarshal(bs, &ts); err != nil {
return nil, xerrors.Errorf("Failed to Unmarshal JSON. err: %w", err)
}

if len(ts) < n {
Expand Down

0 comments on commit 2abe218

Please sign in to comment.