InfoQ

InfoQ

News

My Bookmarks

Login or Register to enable bookmarks for unlimited time.

The content has been bookmarked!

There was an error bookmarking this content! Please retry.

Client Side Storage Momentum Continues with PersistJS and MySpace Adoption of Gears

Posted by Matthew Bass on May 30, 2008

Sections
Development
Topics
Javascript ,
Java
Tags
Google Gears ,
PersistJS
PersistJS was released last week by Paul Duncan. It's a JavaScript framework enabling client-side data storage. Such storage is primarily used by web applications that are capable of running offline. PersistJS has several advantages over other frameworks that perform client-side storage.

Why not just use cookies?

Cookies have been the traditional solution for client-side storage in the past. Frameworks like PersistJS are becoming more popular, though, because there are several disadvantages to using cookies. For example, cookies are limited to 4 kilobytes in size. They are also sent along with every HTTP transaction, wasting bandwidth, and can be complex to create and update.

What makes PersistJS better?

  • It's very small (only 3k when gzipped)
  • It has a consistent API, regardless of the browser being used
  • It doesn't require browser plugins or other libraries
  • It falls back to cookies if unsupported in the current browser
  • It claims to support upcoming versions of IE, Firefox, and Safari
It also uses a compatibility testing strategy as opposed to browser testing. This means that instead of checking if a specific version of IE is supported, it instead checks that the individual calls it uses are supported in the version of IE being used. A browser that fails to support a particular call, for example, won't necessarily be rejected outright.

Usage examples

Saving data in a client-site store is as simple as:
var store = new Persist.Store('My Data Store');
var data = "some arbitrary data of varying length";
store.set('saved_data', data);
Retrieval requires a callback, but is just as easy:
store.get('saved_data', function(ok, val) {
if (ok) alert('saved data = ' + val);
});

Other client-side storage solutions

Dojo Storage and Google Gears also provide client-side storage. Relying on a browser plugin like this can be problematic though, because not everyone will have the plugin installed.

There are several other differences worth noting as well.

Dojo Storage

  • Pro: better documented and has a larger user base
  • Con: only supports Internet Explorer if the Flash plugin is installed
  • Con: doesn't support WebKit-based browsers (like Safari)
  • Con: requires other Dojo libraries to operate

Google Gears

  • Pro: backed by Google and, as with Dojo, is better documented
  • Con: is not yet widely deployed
  • Con: won't operate if the plugin isn't installed

Aside from storage, Gears also supports client-side searching. MySpace made an announcement at the Google I/O conference in San Francisco this week that they are now using Gears for message searching. Up until now, users had to page through their messages to find what they were looking for. With the Gears solution in place, full-text searches are performed on the client side. Searches are also live, bringing back results as the user types in terms.

Note that PersistJS supports a number of different backends, including Gears. The advantage that PersistJS gives in this case is a consistent API that will remain the same if the backend is changed.

No comments

Watch Thread Reply

Educational Content

10 tips on how to prevent business value risk

One category of risk that project teams need to ensure they address is business value failure – delivering a product that fails to provide value for the business investor.

Interview: Software Systems Architecture: Working With Stakeholders Using Viewpoints and Perspectives

InfoQ spoke to the authors of Software Systems Architecture on a couple of new topics, the System Context viewpoint and Agile, which have been added to the second edition.

Beauty Is in the Eye of the Beholder

Alex Papadimoulis discusses ugly code, where it comes from, how to avoid it, and how to get rid of it.

Architecting Visa for Massive Scale and Continuous Innovation

John Davies examines Visa’s architecture and shows how enterprises have architected complex integrations incorporating Hadoop, memcached, Ruby on Rails, and others to deliver innovative solutions.

Max Protect: Scalability and Caching at ESPN.com

Sean Comerford unveils ESPN.com’s architecture, what components are used and why, and the current changes the website goes through.

The Seven Deadly Sins of Enterprise Agile Adoption

Are there repeated patterns of failure on Enterprise Agile Enablement efforts? Sanjiv and Arlen discuss Seven Deadly Sins to avoid when adopting Agile in an enterprise.

Questions for an Enterprise Architect

Erik Dörnenburg answers: What is Enterprise and Evolutionary Architecture?, discussing 4 issues: Turning strategy into execution, Ensuring conformance, Where do the architects sit? Buying or building?

Wrap Your SQL Head Around Riak MapReduce

Sean Cribbs explains what Map-Reduce and Riak are, why and how to use Map-Reduce with Riak, and how to convert SQL queries into their Map-Reduce equivalents.