mrjoelkemp / html5-local-redis

Redis-like API for HTML5 Local Storage
http://mrjoelkemp.github.com/html5-local-redis/
MIT License
20 stars 0 forks source link

Should localRedis be a static object? #28

Closed mrjoelkemp closed 12 years ago

mrjoelkemp commented 12 years ago

Static objects are those that cannot be instantiated; they exist as a singleton. The benefits are mostly performance related; however, static object method calls are significantly faster than both module pattern and prototypal method calls.

The only thing that has to be worked out is how to extend the localRedis object with additional methods and APIs.

The implementation could resemble this:

(function (window) {

/* private methods here */

var storage = window.localStorage,
    localRedis = {
        get: function (key) {},
        set: function (key, value) {},
        /*  more api commands */
    };

window.localRedis = localRedis;
})(window);