Cache icon indicating copy to clipboard operation
Cache copied to clipboard

Retrieve size of file without loading/transforming

Open richardpineo opened this issue 3 years ago • 4 comments

For my application I would like to display the sizes for the individual cached files on disk. This is possible using the method:

let entry = DiskStorage.entry(forKey key: String)

And then using the filePath property of the returned entry.

The issue is that when the cached files are large, the overhead of loading and transforming the data is quite noticeable, even for a file that isn't all that big (the one for my application is only 7MB).

Possible solutions:

  • expose makeFilePath to allow clients to inspect the file directly.
  • flags or alternate entry method that does not load and transform the data.

richardpineo avatar Aug 07 '20 20:08 richardpineo

Hi @richardpineo, I believe the intention of the project was to store lightweight data, you might want to consider forking the project or doing a custom made solution for your problem. Sorry for not being more helpful!

3lvis avatar Oct 04 '20 09:10 3lvis

Thanks for the response! Will consider forking the project or just dealing with the inefficiencies since this part of app isn't speed-critical.

richardpineo avatar Oct 04 '20 17:10 richardpineo

Ok, @richardpineo! Take care

3lvis avatar Oct 04 '20 17:10 3lvis

As a related issue here, it would be great to have a faster check to see if the file exists as the current method existsObject loads and parses the data, which isn't necessary and when caching a lot of options can be a significant performance hit.

This would be easy to implement but the required properties (e.g. file path) are internal.

richardpineo avatar Feb 10 '23 20:02 richardpineo

Closing, reason outdated issue.

3lvis avatar Mar 26 '24 05:03 3lvis