revert cache.go

This commit is contained in:
Felipe Andrade 2023-05-11 15:45:33 -07:00
parent 491369d32f
commit ef42dde6e1

@ -12,7 +12,6 @@ import (
type Cache interface {
Get(ctx context.Context, key string) (string, error)
Put(ctx context.Context, key string, value string) error
Clear(ctx context.Context) error
}
const (
@ -43,11 +42,6 @@ func (c *cache) Put(ctx context.Context, key string, value string) error {
return nil
}
func (c *cache) Clear(ctx context.Context) error {
c.lru.Purge()
return nil
}
type redisCache struct {
rdb *redis.Client
}
@ -81,29 +75,6 @@ func (c *redisCache) Put(ctx context.Context, key string, value string) error {
return err
}
func (c *redisCache) Clear(ctx context.Context) error {
patterns := []string{"lvc:*", "method:*"}
for _, p := range patterns {
scmd := c.rdb.Keys(ctx, p)
err := scmd.Err()
if err != nil {
RecordRedisError("CacheClear")
return err
}
keys, _ := scmd.Result()
icmd := c.rdb.Del(ctx, keys...)
err = icmd.Err()
if err != nil {
RecordRedisError("CacheClear")
return err
}
}
return nil
}
type cacheWithCompression struct {
cache Cache
}
@ -132,10 +103,6 @@ func (c *cacheWithCompression) Put(ctx context.Context, key string, value string
return c.cache.Put(ctx, key, string(encodedVal))
}
func (c *cacheWithCompression) Clear(ctx context.Context) error {
return c.cache.Clear(ctx)
}
type GetLatestBlockNumFn func(ctx context.Context) (uint64, error)
type GetLatestGasPriceFn func(ctx context.Context) (uint64, error)