[whatwg] Supporting eviction in WebStorage
ian at hixie.ch
Thu Feb 4 03:49:54 PST 2010
On Thu, 24 Dec 2009, Kyle Scholz wrote:
> A common application of WebStorage will be clientside caching. Since
> there are limits on store size, developers will be implementing eviction
> schemes, but this is currently difficult because the interface doesn't
> expose store size or get/set times for entries. Some additions to the
> Storage interface would support most use cases:
> totalSize() - Indicates the absolute size of the store.
Different UAs will use different storage mechanisms, leading to different
sizes for the same content. It's not clear exactly how to define this,
especially now that values can be types other than strings.
> availableSize() - Indicates available space in the store.
This is even harder to define. We considered it in depth about a year ago,
but in the end couldn't find a way to define this interoperably.
> keysByAccessTime() - Returns a list of keys in ascending order by access time.
> accessItem() - Sets the access time of an entry to now.
> setItem() will always set the access time of an item. getItem() will
> not set the access time of an item. This makes it possible for the
> developer to determine whether they wish to enable a
> least-recently-stored or least-recently-accessed eviction policy. A
> developer should follow calls to getItem() with a call to accessItem()
> if they wish eviction candidates to be ordered by access time.
I agree that this could be useful in a future version, but in the
meantime, authors can fake it by storing the time manually in a parallel
key, so I haven't added it yet. It'll be interesting to see if people do
this, or if it isn't actually that important.
Ian Hickson U+1047E )\._.,--....,'``. fL
http://ln.hixie.ch/ U+263A /, _.. \ _\ ;`._ ,.
Things that are impossible just take longer. `._.-(,_..'--(,_..'`-.;.'
More information about the whatwg