var CONST_CACHE_ELEMENT_SEPERATOR = '&';
var CONST_CACHE_VALUE_SEPERATOR = '=';
function Cache()
{
	this.addProperty('', 'dictionary', new Array());
	with(Cache)
	{
		method('get', function(key)
		{
			if(typeof(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(typeof(this.getDictionary()[x]) == 'undefined' || typeof(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] == '' || typeof(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]);
			}
		});
	}
}
