Skip to content

Commit dc140e8

Browse files
committed
Refactor cache file path computation into a helper function.
1 parent d18b58e commit dc140e8

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

internal/services/ossrealtime/osscache/oss-realtime-cache.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ func ReadCache() *Cache {
3838
}
3939

4040
func WriteCache(cache Cache, cacheTTL *time.Time) error {
41-
tempFolder := os.TempDir()
42-
cacheFilePath := fmt.Sprint(tempFolder, "/", cacheFileName)
41+
cacheFilePath := GetCacheFilePath()
4342
file, err := os.Create(cacheFilePath)
4443
if err != nil {
4544
return fmt.Errorf("failed to create osscache file: %w", err)
@@ -79,3 +78,8 @@ func AppendToCache(packages *wrappers.OssPackageResponse) error {
7978
}
8079
return WriteCache(*cache, &cache.TTL)
8180
}
81+
82+
func GetCacheFilePath() string {
83+
tempFolder := os.TempDir()
84+
return fmt.Sprint(tempFolder, "/", cacheFileName)
85+
}

0 commit comments

Comments
 (0)