[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-30 Thread Joran Greef

Thanks for the links will do. Hope it's also helpful to the discussion
at hand.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-30 Thread kangax

On Sep 30, 5:15 am, Joran Greef  wrote:
[..]
> In other words, setting about 1000 objects to local storage takes
> about 3.3 milliseconds in Safari and 2 seconds(!) in Firefox.

localStorage is not the most stable component in Firefox, but it's
getting there :)

I recently filed a ticket related to clearing (https://
bugzilla.mozilla.org/show_bug.cgi?id=510234). There's also a minor
discrepancy with `key` (https://bugzilla.mozilla.org/show_bug.cgi?
id=509241), and few others that you can find on a bugtracker.

Please, file a bug.

[...]

--
kangax
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-30 Thread kangax

On Sep 30, 6:00 am, Joran Greef  wrote:
> Here's another interesting thing in Safari 4 I just found:
>
> localStorage.clear();
> localStorage.setItem('hello', 'world');
> localStorage.getItem('hello'); // Returns 'world'
> localStorage['hello']; // Returns 'world'
> localStorage.hello; // Returns 'world'
>
> localStorage.clear();
> localStorage.setItem('getItem', 'world');
> localStorage.getItem('getItem'); // Returns "TypeError: Result of
> expression 'localStorage.getItem' [hello] is not a function."
> localStorage['getItem']; // Returns 'world'
> localStorage.getItem; // Returns 'world'

Good find. File a bug with WebKit, please (https://bugs.webkit.org/
enter_bug.cgi).

I'm sure they'll fix it in a matter of days.

--
kangax
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-30 Thread andris

On Sep 30, 12:19 pm, Joran Greef  wrote:
> On a side-note, I think local storage will soon become as important to
> client-side code as AJAX, and (at least at this stage) it also seems
> to suffer from browser incompatibilities. "Never say never". ;)

I couldn't agree more.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-30 Thread andris

On Sep 30, 10:05 am, andris  wrote:
> > Nope. I mean clean-side database storage -  > webkit-does-html5-client-side-database-storage/>
>
> Wow that's cool, I don't use Safari myself so I wasn't aware of that.

I tried to implement the openDatabase support (I dind't find any
documentation though :S) but wasn't very successful. openDatabase
queries seem to be asynchronous (I execute the query but the results
come a little bit later) and that doesn't fit with with my caching
system, which provides the data of the cached items immediatelly after
the initialization of the module. With openDatabase the module is
still waiting for the results from the database while the
initialization is already done and program flow goes on.

I'd probably need to redesign the module in order to get it working
with the openDatabase support.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-30 Thread Joran Greef

Here's another interesting thing in Safari 4 I just found:

localStorage.clear();
localStorage.setItem('hello', 'world');
localStorage.getItem('hello'); // Returns 'world'
localStorage['hello']; // Returns 'world'
localStorage.hello; // Returns 'world'

localStorage.clear();
localStorage.setItem('getItem', 'world');
localStorage.getItem('getItem'); // Returns "TypeError: Result of
expression 'localStorage.getItem' [hello] is not a function."
localStorage['getItem']; // Returns 'world'
localStorage.getItem; // Returns 'world'
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-30 Thread Joran Greef

On a side-note, I think local storage will soon become as important to
client-side code as AJAX, and (at least at this stage) it also seems
to suffer from browser incompatibilities. "Never say never". ;)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-30 Thread Joran Greef

This is timely. I've been working with window.localStorage for the
past couple months now and initially I wrote a nice and simple wrapper
for it that also provides an in-memory cache where clients do not
support window.localStorage. I rewrote it a couple times since then
and thought I had something useable.

Last week I did some tests on Firefox 3.5 and Safari 4 on my machine.
For 10,000 iterations it turns out that Safari can do setItem('key',
'value') at a rate of about 1 item every 0.0033ms. Firefox on the
other hand takes 2ms per item. From what I've read, it seems that
Safari's implementation uses an in-memory cache before writing to disk
but that Firefox writes directly to disk and gets IO-bound.

In other words, setting about 1000 objects to local storage takes
about 3.3 milliseconds in Safari and 2 seconds(!) in Firefox.

So I've now rewritten the wrapper to use an internal queue, throttle
localStorage use based on browser, and provide asynchronous get, set
and unset methods with callback options.

Hope this helps. Have you found similar results?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-30 Thread Yaffle

May I ask you about localStorage?

I want to update some property, but no space left on device and
FireFox throws error "NS_ERROR_FILE_NO_DEVICE_SPACE",
so "localStorage[property]" stays unchanged.

try{
  localStorage[property] = value; //throws
"NS_ERROR_FILE_NO_DEVICE_SPACE"
}catch(e){
  localStorage.removeItem(property);// also throws
"NS_ERROR_FILE_NO_DEVICE_SPACE"
}

How to update property or remove it at all?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-30 Thread andris

> I use "small" (40 lines of code) storage class, that uses cookies or
> localStorage.

I wasn't able to use cookies for two reasons

a) Cookies aren't ment for data storing but for token storing, so they
provide EXTREMELY limited space. It's hard to push hundreds of
kilobytes into cookies.

b) My intention was to use this module with a website with very heavy
load - millions of pageviews per day. Storing data in a cookie means
that this data is being passed around between the browser and the
server with every request made to the server (while loading images,
static files, etc.). Every kilobyte of data for one million requests
makes about 1 GB of extra traffic. It's not much compared to the
overall traffic, but it's stil 1 GB per day. And I would like to store
not 1 kB but hundreds of kilobytes data. Without the cookies, data is
pulled from the server only when there's actual need, not with every
request.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-30 Thread andris

> Nope. I mean clean-side database storage -  webkit-does-html5-client-side-database-storage/>

Wow that's cool, I don't use Safari myself so I wasn't aware of that.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-29 Thread Yaffle

Yes that's is, but Safari and Chrome isn't popular browsers.(depends
on site audience)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-29 Thread kangax



On Sep 30, 12:01 am, Yaffle  wrote:
[...]
> database works in webkit, which supports localStorage.

Not in Safari 3 and not in any version of Chrome as of now (although,
Chrome is working on `localStorage` at the moment -
http://code.google.com/p/chromium/issues/detail?id=4360).

Both - Safari 3 and Chrome - have database storage, though.

--
kangax
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-29 Thread Yaffle

I use "small" (40 lines of code) storage class, that uses cookies or
localStorage.

IMHO, userData and databases not so usefull:
IE userData behavior relies on DOM.
database works in webkit, which supports localStorage.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-29 Thread kangax

On Sep 29, 5:48 pm, andris  wrote:
> Thank you for the replies!
>
> > Why don't you use database abstraction when available? It would fill
> > in those Safari 3 and Chrome gaps.
>
> Do you mean database abstraction as a server side database? My point
> was only to use browser-side for the caching.

Nope. I mean clean-side database storage - 

[...]

--
kangax
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-29 Thread Mark Holton
On Tue, Sep 29, 2009 at 1:37 PM, kangax  wrote:


>
> I can't speak for everyone in the core, but most definitely not. This
> is clearly more suited for a standalone "module".
>
>
Actually, you changed my [user] mind.  Module makes more sense.  Core libs
shouldn't get bloated.

(but this is good to know about, thanks!)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-29 Thread andris

Thank you for the replies!

> Why don't you use database abstraction when available? It would fill
> in those Safari 3 and Chrome gaps.

Do you mean database abstraction as a server side database? My point
was only to use browser-side for the caching.

> On a side note, I haven't noticed any unit tests; only functional ones
> on the front page.

Sorry for that, the idea struck me yesterday and I immediately tried
to implement it (along with the domain registration and so on:) ), so
there hasn't been much time to come up with the correct tests.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-29 Thread kangax

On Sep 29, 10:12 am, andris  wrote:
> Hi,
>
> I've implemented a simple library on the top of DOM storage and IE
> userData to act as a browser side caching solution called DOMCached
> (www.domcached.com). The library acts like a kind of javascript
> memcached caching solution - a script can store objects to the cache
> and retrieve it later on another pageview.
>
> For example if the user is already made an Ajax request and the data
> is stored to the DOMCache then there is no need to do this request to
> the server again. Or if you try to fill out a form and your browser
> crashes - if the data was stored to the cache by the script then
> nothing is lost when you re-open the form. And so on, the
> possibilities are endless.

I've done something similar (although not publicly available yet) :)

Why don't you use database abstraction when available? It would fill
in those Safari 3 and Chrome gaps.

>
> Anyhow - I was wondering if similar functionality (or DOMCached
> itself) could be added to the Prototype library?

I can't speak for everyone in the core, but most definitely not. This
is clearly more suited for a standalone "module".

On a side note, I haven't noticed any unit tests; only functional ones
on the front page.

--
kangax
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---



[Prototype-core] Re: Suggestion: DOM storage methods to Prototype

2009-09-29 Thread Mark Holton
On Tue, Sep 29, 2009 at 7:12 AM, andris  wrote:

>
> Hi,
>
> I've implemented a simple library on the top of DOM storage and IE
> userData to act as a browser side caching solution called DOMCached
> (www.domcached.com). The library acts like a kind of javascript
> memcached caching solution - a script can store objects to the cache
> and retrieve it later on another pageview.
>
> For example if the user is already made an Ajax request and the data
> is stored to the DOMCache then there is no need to do this request to
> the server again. Or if you try to fill out a form and your browser
> crashes - if the data was stored to the cache by the script then
> nothing is lost when you re-open the form. And so on, the
> possibilities are endless.
>
> Anyhow - I was wondering if similar functionality (or DOMCached
> itself) could be added to the Prototype library?
>
>
> Best regards,
> Andris Reinman
>
>
+1
As a user of Prototype, I'd like to see something like this added.  Clean,
simple and useful.
Mark

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Prototype: Core" group.
To post to this group, send email to prototype-core@googlegroups.com
To unsubscribe from this group, send email to 
prototype-core-unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-core?hl=en
-~--~~~~--~~--~--~---