Lasso Soft Inc. > Home

[cache_info]

Linkcache_info
AuthorJason Huck
CategoryUtility
Version8.5.x
LicensePublic Domain
Posted08 Apr 2008
Updated13 May 2009
More by this author...

Description

This tag returns a map of information about the specified cache, including its id, type, content, and last refresh date. Returns null if the specified cache is not found. The map elements are: content, stat_fetch, type, id, stat_store, and date. Useful if you need to know when a cache was created, vs. when it will expire.

Sample Usage

cache_info('mycache')->find('date');

-> 2008-04-08 14:12:44

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

define_tag(
	'info',
	-namespace='cache_',
	-req='name', -copy,
	-opt='session',
	-opt='useglobal',
	-priority='replace',
	-description='Returns information about the specified cache.'
);
	// cache storage mechanism changed as of 8.5.6
	if(!lasso_tagexists('cache_maintenance'));
		// map elements: content, stat_fetch, type, id, stat_store, date
	
		// add the server name to the cache name if host-specific caches is enabled
		cache_preferences->find('_cache_host') == 'Y' ? #name += '|' + server_name;

		// return null if there are no caches or the specified cache does not exist		
		!global_defined('_Cache_Storage') || $_Cache_Storage->find(#name) == '' ? return;
		
		// return a reference to the specified cache
		return(@$_Cache_Storage->find(#name));
	else;
		!local_defined('useglobal') ? local('useglobal') = true;
	
		\cache_internal->eval;

		if(#useglobal);
			thread_atomic(globals->find(#c_prefix + 'fetch'));
				globals->insert((#c_prefix + 'fetch') = integer(globals->find(#c_prefix + 'fetch')) + 1);
				local('fetch') = globals->find(#c_prefix + 'fetch');
				local('content') = globals->find(#c_prefix + 'content');
				local('date') = globals->find(#c_prefix + 'date');
				local('store') = @globals->find(#c_prefix + 'store');
			/thread_atomic;
		else;
			vars->insert((#c_prefix + 'fetch') = integer(vars->find(#c_prefix + 'fetch')) + 1);
			local('fetch') = vars->find(#c_prefix + 'fetch');
			local('content') = vars->find(#c_prefix + 'content');
			local('date') = vars->find(#c_prefix + 'date');
			local('store') = @vars->find(#c_prefix + 'store');
		/if;
					
		local('out') = map(
			'content' = #content,
			'stat_fetch' = #fetch,
			'type' = #c_type,
			'id' = null,
			'stat_store' = #store,
			'date' = #date
		);
		
		return(#out);
	/if;
/define_tag;

Related Tags

Comments

13 May 2009, Jason Huck

Updated for 8.5.6.

Contains a quick'n'dirty fix for the changes in Lasso's caching system introduced in 8.5.6.

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft