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

IndexedDB: Syntax for specifying persistent/temporary storage

From: Jan Varga <jan.varga@gmail.com>
Date: Fri, 6 Dec 2013 16:19:37 +0100
Message-ID: <CAB1sDKxxCrCS4wr7XBKY2WPxRmfOTL8dhwyC--T58gA4YntMRQ@mail.gmail.com>
To: Webapps WG <public-webapps@w3.org>
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.
We might need to add other parameters in future so we propose creating
a dictionary with a "version" and
"storage" property for now.

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);
};

enum StorageType { "persistent", "temporary" };

dictionary IDBOpenDBOptions
{
    [EnforceRange] unsigned long long version;
    StorageType storage;
};

Some simple examples:

Example 1a - Opening a database in default storage:
var request = indexedDB.open('AddressBook', 15);
request.onsuccess = function(evt) {...};
request.onerror = function(evt) {...};
Example 1b - Deleting a database in default storage:
var request = indexedDB.deleteDatabase("AddressBook");request.onsuccess
= function(evt) {...};
request.onerror = function(evt) {...};
Example 2a - Opening a database in temporary storage:
var request = indexedDB.open("AddressBook", { version: 15, storage:
"temporary" });request.onsuccess = function(evt) {...};
request.onerror = function(evt) {...};

Example 2b - Deleting a database in temporary storage:
var request = indexedDB.deleteDatabase("AddressBook", { storage:
"temporary" });request.onsuccess = function(evt) {...};
request.onerror = function(evt) {...};

What do you think ?

[1] https://developers.google.com/chrome/whitepapers/storage

Jan
Received on Friday, 6 December 2013 15:20:05 UTC

This archive was generated by hypermail 2.3.1 : Friday, 6 December 2013 15:20:05 UTC