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

Create policy based on size #1

Open
rturk opened this issue Jan 1, 2016 · 3 comments
Open

Create policy based on size #1

rturk opened this issue Jan 1, 2016 · 3 comments

Comments

@rturk
Copy link

rturk commented Jan 1, 2016

Constrains in mobile phones are mostly related to storage. Discuss Create policy based on size X bytes (GB, MB, KB) ...

@timfpark
Copy link
Owner

timfpark commented Jan 2, 2016

Yup - makes sense - would love a PR for this. I mostly used count in my initial implementation because the items I am storing in my app are all the same size...

@vincentjames501
Copy link

+1

@DarkMatterMatt
Copy link
Contributor

I'd like to PR this.

I see a two main ways to do it:

  1. Have a single _size entry (similar to _lru) that gets updated every time an entry is added/removed. This would add ~50% of the number of backend calls when adding/removing items because of having to get/set _size as well as _lru. When removing the item we will also have to backend.getItem the value (as well as backend.removeItem) in order to update _size.
  2. Track the _size and _lru in a single _metadata entry (e.g. metadata = { size: 0, lru = [[key1], [size1]] }). This requires more code changes, but I think it would result in a better implementation. When removing key1 we could just subtract size1 from the current size.

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

4 participants