Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need help about caching #99

Open
CavalcanteLeo opened this issue Apr 18, 2018 · 3 comments
Open

Need help about caching #99

CavalcanteLeo opened this issue Apr 18, 2018 · 3 comments

Comments

@CavalcanteLeo
Copy link

I have an app, that is a comic book reader, so the user can download a book then read it later, even without internet.

I'm thinking to cache all pages(images) of the book with SPTPersistentCache.
I need to save each book in a different folder, ex: spider man will be saved on a folder spider-man/pages, minions will be saved on minions/pages and so on...

Also SPTPersistentCache can't garbage the books downloaded, it must keep the cache until the user delete that specific book. Also no disk size limite.

What I need is the very same way Spotify does with offline musics downloaded. Can I do that?

@chrisbtreats
Copy link
Contributor

I don't know about the file paths but you can prevent garbage collection on cached items by "locking" them using the lockDataForKeys:callback:onQueue

@CavalcanteLeo
Copy link
Author

CavalcanteLeo commented Apr 20, 2018

Thanks @chrisbtreats lockDataForKeys:callback:onQueue works perfect for what I need

The idea behind the folder is to show the user how much storage to book is taking.
Each book can have several pages, each page is an image.
So, i need to calculate something like this:

book_1: 115MB
book_2: 333.3MB
book_3: 514.3MB

If there is another way to calculate the size of an array of keys, I won't need to change the folder

totalUsedSizeInBytes shows the entry cache, not for a couple of keys related to a specific book

But if I can't do that, it will be so easy to calculate a size of a specific folder

@CavalcanteLeo
Copy link
Author

CavalcanteLeo commented Apr 20, 2018

I just read all the code, and it's not possible, but looks like it's possible to change the folder for each instance.

Also i will create that feature and submit a PR, something like: totalUsedSizeInBytesForKeys:callback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants