Major code cleanup

This commit is contained in:
Jacob Gunther
2023-02-24 09:48:40 -06:00
parent 94f42a4af5
commit 4d926e5976
3 changed files with 169 additions and 268 deletions

View File

@@ -52,7 +52,7 @@ func (r *Redis) GetString(key string) (string, bool, error) {
return result.Val(), true, result.Err()
}
func (r *Redis) GetBytes(key string) ([]byte, bool, error) {
func (r *Redis) GetBytes(key string) ([]byte, error) {
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
defer cancel()
@@ -60,32 +60,32 @@ func (r *Redis) GetBytes(key string) ([]byte, bool, error) {
existsResult := r.conn.Exists(ctx, key)
if err := existsResult.Err(); err != nil {
return nil, false, err
return nil, err
}
if existsResult.Val() == 0 {
return nil, false, nil
return nil, nil
}
result := r.conn.Get(ctx, key)
if err := result.Err(); err != nil {
return nil, true, err
return nil, err
}
data, err := result.Bytes()
return data, true, err
return data, err
}
func (r *Redis) GetNRGBA(key string) (*image.NRGBA, bool, error) {
value, ok, err := r.GetBytes(key)
value, err := r.GetBytes(key)
if err != nil {
return nil, false, err
}
if !ok {
if value == nil {
return nil, false, nil
}