var CONST_CACHE_ELEMENT_SEPERATOR = '%!%';
var CONST_CACHE_VALUE_SEPERATOR = '~!~';
function Cache(){
	this.addProperty('', 'dictionary', new Object());
	with(Cache){
		method('get', function(key){
			if(this.getDictionary()[key] == undefined){
				return null;
			}
			return this.getDictionary()[key].value;
		});
		method('put', function(key, value){
			var val = new Object;
			val.key = key;
			val.value = value;
			this.getDictionary()[key] = val;
		});
		method('remove', function(key){
			this.getDictionary()[key] = undefined;
		});
		method('toMemento', function(){
			var str = '';
			for(x in this.getDictionary()){
				if(this.getDictionary()[x] == undefined || this.getDictionary()[x].key == undefined){
					continue;
				}
				str += this.getDictionary()[x].key + CONST_CACHE_VALUE_SEPERATOR + this.getDictionary()[x].value + CONST_CACHE_ELEMENT_SEPERATOR;
			}
			return str;
		});
		method('fromMemento', function(memento){
			var array = memento.split(CONST_CACHE_ELEMENT_SEPERATOR);
			this.setDictionary(new Object());
			for(x in array){
				if(array[x] == '' || array[x] == undefined || array[x] == null || typeof(array[x]) == 'function'){
					continue;
				}
				var item = array[x].split(CONST_CACHE_VALUE_SEPERATOR);
				this.put(item[0], item[1]);
			}
		});
	}
}

