
module.exports = do ->
	_namespace = 'e_gd_c'
	_cache_exp = 10000#cache expires after 10s
	# _cache = JSON.parse localStorage.getItem(_namespace) or '{}'
	_cache = {}
	init: (namespace, cache_exp) ->
		_namespace = namespace
		_cache_exp = cache_exp
	clear: (prefix, id) ->
		return _cache[prefix] = {} unless id
		_cache[prefix]?[id] = null
	set: (prefix, id, value) ->
		(_cache[prefix] or= {})[id] = value
		_cache[prefix][id].__exp__ = +new Date + _cache_exp
		# localStorage.setItem _namespace, JSON.stringify _cache
	check: (prefix, id) ->
		_cache[prefix]?[id]?.__exp__ > +new Date
	get: (prefix, id) ->
		_cache[prefix]?[id]
