Skip to content

Commit

Permalink
fix filename
Browse files Browse the repository at this point in the history
  • Loading branch information
AnieeG committed Apr 6, 2024
1 parent 32d3fef commit 31171d9
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions integration-tests/ccip-tests/utils/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ func (c *Cache) SetMaxSize(size int64) {

func (c *Cache) SaveCurrentStateAndReset() error {
resetCount := c.resetCount.Load() + 1
filePath := fmt.Sprintf("%s_%d", c.filePath, resetCount)

filePath := fmt.Sprintf("%s_%d.fastcache", c.filePath, resetCount)
err := c.cache.SaveToFile(filePath)
if err != nil {
return fmt.Errorf("error %w saving the cache into file %s", err, filePath)
Expand Down Expand Up @@ -77,8 +78,8 @@ func (c *Cache) Load(key []byte, value any) (bool, error) {
dstBytes, exists = cache.HasGet(dstBytes, key)
// if the cache has already been reset, check if the key exists in previous versions
if !exists && c.resetCount.Load() > 0 {
for i := int64(0); i < c.resetCount.Load(); i++ {
filePath := fmt.Sprintf("%s_%d", c.filePath, i)
for i := int64(1); i < c.resetCount.Load(); i++ {
filePath := fmt.Sprintf("%s_%d.fastcache", c.filePath, i)
c1, err := fastcache.LoadFromFile(filePath)
if err != nil {
return false, fmt.Errorf("error %w loading cache from back up file %s", err, filePath)
Expand All @@ -105,7 +106,7 @@ func NewCache(maxBytes int, cacheName string) *Cache {
if err != nil {
panic(err)
}
filePath := filepath.Join(tmpDir, fmt.Sprintf("%s.fastcache", cacheName))
filePath := filepath.Join(tmpDir, cacheName)
return &Cache{
maxSize: DEFAULTMAXSIZE,
filePath: filePath,
Expand Down

0 comments on commit 31171d9

Please sign in to comment.