Documentation

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
v2.0:modules:cache [2012/02/16 00:50]
Franz #368: Add API section stub
v2.0:modules:cache [2012/06/22 14:09] (current)
Franz #368: Clean up example code.
Line 58: Line 58:
 === Code === === Code ===
 <​code=php>​ <​code=php>​
 +use \fluxbb\cache;​
 +
 // We want a file-based cache in the /​tmp/​php-cache/​ dir - this will be created if possible. Obviously this path won't work on Windows! // We want a file-based cache in the /​tmp/​php-cache/​ dir - this will be created if possible. Obviously this path won't work on Windows!
-$cache = \fluxbb\cache\Cache::​load('​File',​ array('​dir'​ => '/​tmp/​php-cache/'​));​+$cache = Cache::​load('​File',​ array('​dir'​ => '/​tmp/​php-cache/'​));​
  
 // If we have the mcrypt extension let's encrypt the cache // If we have the mcrypt extension let's encrypt the cache
Line 70: Line 72:
 // Check if there is already a value cached // Check if there is already a value cached
 $value = $cache->​get('​test'​);​ $value = $cache->​get('​test'​);​
-echo ($value === \fluxbb\cache\Cache::​NOT_FOUND ? 'Value not found in cache.'​ : '​Value:​ '​.$value)."​\n";​+echo ($value === Cache::​NOT_FOUND ? 'Value not found in cache.'​ : '​Value:​ '​.$value)."​\n";​
  
 // Store a new unique ID in the cache // Store a new unique ID in the cache
Line 80: Line 82:
 // Check that the new value was stored correctly // Check that the new value was stored correctly
 $value = $cache->​get('​test'​);​ $value = $cache->​get('​test'​);​
-echo ($value === \fluxbb\cache\Cache::​NOT_FOUND ? 'Value not found in cache.'​ : '​Value:​ '​.$value)."​\n";​+echo ($value === Cache::​NOT_FOUND ? 'Value not found in cache.'​ : '​Value:​ '​.$value)."​\n";​
 </​code>​ </​code>​