Lasso Soft Inc. > Home

[cache_names]

Linkcache_names
AuthorJason Huck
CategoryUtility
Version8.x
LicensePublic Domain
Posted21 Oct 2005
Updated13 May 2009
More by this author...

Description

Returns an array of all the current cache names.

Sample Usage

// delete all caches that start with 'mysite_'
iterate(cache_names, local('i'));
	#i->beginswith('mysite_') ? cache_delete( -name=#i);
/iterate;

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(
	'names',
	-namespace='cache_',
	-opt='session',
	-priority='replace',
	-description='Returns all the currently stored cache names as an array.'
);
	local('out' = array);
	
	// caching system changed as of 8.5.6
	if(!lasso_tagexists('cache_maintenance'));
		iterate(global('_Cache_Storage'), local('this'));
			#out->insert(#this->first->split('|')->get(1));
		/iterate;
	else;		
		define_tag(
			'getname', 
			-req='src', -copy,
			-opt='session'
		);
			local('cachekeys') = array(
				'_local',
				'_global',
				'_' + server_name,
				'_' + (local_defined('session') ? session_id(#session) | 'session')
			);

			local('name') = string;
			
			iterate(#cachekeys, local('i'));
				if(#src >> #i);
					#name = #src->removeleading('_cache_')&split(#i)->first;
				/if;
			/iterate;
			
			return(#name);
		/define_tag;
	
		iterate(globals->keys, local('i'));
			if(
				#i->beginswith('_cache_')
				&& #i !>> 'preference'
				&& #i !>> 'lastexpiration'
			);
				// local('name') = #i->split('_')->get(3);
				local('name') = getname(#i);
				#out !>> #name ? #out->insert(#name);
			/if;
		/iterate;
		
		if(local_defined('session'));
			iterate(vars->keys, local('i'));
				if(#i->beginswith('_cache_'));
					// local('name') = #i->split('_')->get(3);
					local('name') = getname(#i);
					#out !>> #name ? #out->insert(#name, -session=#session);
				/if;
			/iterate;
		/if;
	/if;
	
	return(#out);
/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