﻿/// <reference path="~/Scripts/ByteStorm/_BSC_Interface.js" />
(function()
{
	BSC.D.C = function()
	{
		var storage = {};
		var cache = new Cache();
		//		    http://www.monsur.com/projects/jscache/
		//# cache.setItem("A", "1", {expirationAbsolute: null,   
		//#                          expirationSliding: 60,   
		//#                          priority: CachePriority.High,  
		//#                          callback: function(k, v) { alert('removed ' + k); }  
		//#                         }); 

		return {
			SetItem: function(key, value, options)
			{
				cache.setItem(key, value, options);
			},
			GetItem: function(key)
			{
				cache.getItem(key);
			},
			HasItem: function(key)
			{
				var r = (cache.getItem(key) != undefined);
				return r;
			},
			Clear: function(key)
			{
				cache.getItem("A");
			},
			Put: function(key, value)
			{
				/// <summary>Put object in Cache with. If key exists, object will be overridden.</summary>
				/// <param name="key">Key in cache. Used to recieve object again.</param>
				/// <param name="value">Object to be stored in cache.</param>
				storage[key] = value;
			},
			Get: function(key)
			{
				/// <summary>Get object in Cache</summary>
				/// <param name="key">Key to object</param>
				/// <return>Object from Cache</return>
				if (storage[key])
					return (storage[key]);
				else
					return null;
			},
			Remove: function(key)
			{
				/// <summary>Remove object from cahe/summary>
				/// <param name="key">Key to object</param>
				delete storage[key];
			},
			RemoveAll: function()
			{
				storage = {};
			},
			HasKey: function(key)
			{
				/// <summary>Check if cache has an entry with this key</summary>
				/// <param name="key">Key to object</param>
				/// <return>true if object is in cache</return>
				return (storage[key] != null);
			}
		};
	} ();
})();
