﻿(function ($) {
    $.store2 = {
        maxSize: 20,
        keys: new Array(),
        cache_length: 0,
        items: new Array(),
        setItem: function (pKey, pValue) {
            if (typeof (pValue) != 'undefined') {
                if (typeof (this.items[pKey]) == 'undefined') {
                    this.cache_length++;
                }
                this.keys.push(pKey);
                this.items[pKey] = pValue;

                if (this.cache_length > this.maxSize) {
                    //this.removeOldestItem();
                }
            }
            return pValue;
        },
        removeItem: function (pKey) {
            var tmp;
            if (typeof (this.items[pKey]) != 'undefined') {
                this.cache_length--;
                var tmp = this.items[pKey];
                delete this.items[pKey];
            }
            return tmp;
        },
        getItem: function (pKey) {
            return this.items[pKey];
        },
        hasItem: function (pKey) {
            return typeof (this.items[pKey]) != 'undefined';
        },
        clear: function () {
            var tmp = this.cache_length;
            this.keys = new Array();
            this.cache_length = 0;
            this.items = new Array();
            return tmp;
        }
    };

})(jQuery);



