Cache
Cache copied to clipboard
Retrieve size of file without loading/transforming
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.
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!
Thanks for the response! Will consider forking the project or just dealing with the inefficiencies since this part of app isn't speed-critical.
Ok, @richardpineo! Take care
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.
Closing, reason outdated issue.