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

Re: WebSimpleDB object caching

From: Kris Zyp <kris@sitepen.com>
Date: Tue, 10 Nov 2009 13:24:14 -0700
Message-ID: <4AF9CBEE.2060903@sitepen.com>
To: "Nikunj R. Mehta" <nikunj.mehta@oracle.com>
CC: public-webapps WG <public-webapps@w3.org>
Hash: SHA1

Nikunj R. Mehta wrote:
> Hi Kris,
> Thanks for the insightful feedback.
> On Nov 7, 2009, at 8:12 PM, Kris Zyp wrote:
>> Is there any intended restrictions on caching of objects returned by
>> queries and gets with WebSimpleDB?
> Currently, the spec does specify any required behavior in terms of
> caching objects. As an implementation choice, it would be good if
> the object returned by a database from a cursor can be reused by the
> user agent.
>> For example (using the address book
>> example in the spec):
>> |database = window.openDatabase('AddressBook', '1', 'Address Book',
>> true);
>> database.transaction(function(Transaction txn) {
>> var store = txn.getEntityStore('Contact');
>> var allCursor = store.entities();
>> var lCursor = store.getIndex('ContactName').entities('L');
>> var l1 = lCursor.next();
>> l1 = lCursor.next();
>> var l2 = allCursor.next();
> From this example, the two calls to lCursor.next() may return the
> exact same object each time even though its contents may be
> completely different. In other words, they could respond positively
> to the identity match '===' but not to the equality match '=='. As a
> spec user which one do you prefer? As spec implementors, what would
> you prefer?
>> Now, is there any intended requirement that l1==l2 must be false even
>> if ||they represent the same record (that is l1["id"] === l2["id"]) or
>> can cursors potentially reuse JS objects?
> Cursors can potentially reuse JS objects. Would you object if this
> were to be a requirement of the spec?
>> Also should store.get(l1.id)
>> == l1 be false as well?
> In general, nothing can be said about '==' test, except on
> primitives that are supported by the spec. I currently intend to
> support only String and Number types for use as keys in the spec.
> That means,
> store.get(l1.id).id == l1.id but _not_ store.get(l1.id) == l1
>> In other words, if one does l2.number =
>> '3322', is there any guarantee that l1.number would be unchanged (or
>> would be changed)?
> There is no such guarantee presently. Please explain your
> requirement as that might help shed light on which route to take.
I don't have a hard requirement, we are just using the WebSimpleDB API
as a common interface to different storage system in server side
JavaScript. But, if store.entities().next() !==
store.entities().next() is not guaranteed, it could potentially add an
extra burden on users. If they modify an object return from a cursor,
and have not yet called update or put with it, then it would be
unknown if a future cursor might return the modified object or a fresh
object without the modification. Guaranteeing store.entities().next()
!== store.entities().next() seems like it would provide more
determinism. Alternately, we could guarantee store.entities().next()
=== store.entities().next(), but I don't think you are wanting that,
and it would put extra burden on spec implementors to keep track of
objects that have been returned from cursors.

Presumably the identity guarantee of objects returned from cursors
should be the same as for get(id) calls (if cursors always return a
new JS object, so should get(id)).


- --
Kris Zyp
(503) 806-1841
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
Received on Tuesday, 10 November 2009 20:25:09 UTC

This archive was generated by hypermail 2.3.1 : Friday, 27 October 2017 07:26:20 UTC