[cache_info]

Description

Link: [cache_info]
Author: Jason Huck
Category: Utility
Version: 8.5.x
License: Public Domain
Posted: Apr. 08, 2008
Updated: May. 13, 2009
More by this author...

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.

Parameters

-session string, optional The name of the session in which the cache is stored.
-useglobal boolean, optional Whether the cache is global. Defaults to true.

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.
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
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

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