[cache_names]

Description

Link: [cache_names]
Author: Jason Huck
Category: Utility
Version: 8.x
License: Public Domain
Posted: Oct. 21, 2005
Updated: May. 13, 2009
More by this author...

Returns an array of all the current cache names.

Parameters

-session string, optional Provide a session name if the tag should check for session-specific caches.

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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
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

05/13/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.
Email:


Password:



Newest

Most Popular

Support tagSwap.net