W3C home > Mailing lists > Public > public-webapps@w3.org > October to December 2013

Re: IndexedDB: Syntax for specifying persistent/temporary storage

From: Joshua Bell <jsbell@google.com>
Date: Fri, 6 Dec 2013 10:29:09 -0800
Message-ID: <CAD649j7+608PwfrFpYag8Q2dG13VJBBJtXsU9hOc42_1_0vvJQ@mail.gmail.com>
To: Jan Varga <jan.varga@gmail.com>
Cc: Webapps WG <public-webapps@w3.org>
Thanks for sending this!

On Fri, Dec 6, 2013 at 7:19 AM, Jan Varga <jan.varga@gmail.com> wrote:

> IndexedDB implementation in Firefox 26 (the current beta) supports a new storage type called temporary storage.
> In short, it's a storage with LRU eviction policy, so the least recently used data is automatically deleted when
>
> a limit is reached. Chrome supports something similar [1].
>
> Obviously, the IndexedDB spec needs to be updated to allow specifying different storage types.
>
> Since the spec isn't one of those new-fangled Living Standards, this would
be in a different spec. "Indexed DB Level 2" or something. There hasn't
been a discussion about that yet.

FYI we've been tracking specific items/proposals as RESOLVED/LATER bugs
[1]; there's a Wiki page that desperately needs updating [2] and I had a
doc capturing some discussion notes as well [3].  We should file a tracking
bug for this issue.

We might need to add other parameters in future so we propose creating
a dictionary with a "version" and
>
> "storage" property for now.
>
> Sounds reasonable, since name is always required, keeping it out of the
dict makes sense to me vs. what I captured in [3]. I like how this looks,
although...

>
> Here is the current interface:
> interface IDBFactory {    IDBOpenDBRequest open (DOMString name, [EnforceRange] optional unsigned long long version);    IDBOpenDBRequest <https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBOpenDBRequest> deleteDatabase (DOMString name);    short            cmp (any first, any second);
> };
>
> and the interface with the dictionary:
>
> interface IDBFactory {
>     IDBOpenDBRequest open (DOMString name, [EnforceRange] unsigned long long version);
>     IDBOpenDBRequest open (DOMString name, optional IDBOpenDBOptions options);
>
>     IDBOpenDBRequest deleteDatabase (DOMString name, optional IDBOpenDBOptions options);
>     short cmp (any first, any second);
> };
>
> Issue: How can script detect that this updated API is available?

It seems like this could be done:

var r;
try {
  r = indexedDB.open("db", {version: 1, storage: "temporary"});
  // Throws TypeError on older implementations since Dictionary won't
coerce to Number (?)
} catch (e) {
  // Fall back to default storage type
  r = indexedDB.open("db", 1);
}

... which could be shimmed.

I don't think overloading has many proponents at the moment, though. The
other options are a different method name, or passing |undefined| as the
version, neither of which are great. Allowing null/undefined/0/falsy to
mean "current version" wouldn't be too terrible, though, and isn't a compat
concern since it explicitly throws today.


> enum StorageType { "persistent", "temporary" };
>
> dictionary IDBOpenDBOptions
> {
>     [EnforceRange] unsigned long long version;
>     StorageType storage;
> };
>
>

[1]
https://www.w3.org/Bugs/Public/buglist.cgi?cmdtype=runnamed&list_id=25048&namedcmd=IndexedDB%20Later
[2] http://www.w3.org/2008/webapps/wiki/IndexedDatabaseFeatures
[3]
https://docs.google.com/a/chromium.org/document/d/1vvC5tFZCZ9T8Cwd2DteUvw5WlU4YJa2NajdkHn6fu-I/edit
Received on Friday, 6 December 2013 18:29:37 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 18:14:20 UTC