Elgg  Version master
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Elgg\Cache\SimpleCache Class Reference

Simple cache service. More...

Public Member Functions

 __construct (protected Config $config, protected ViewsService $views)
 Constructor. More...
 
 getUrl (string $view)
 Get the URL for the cached view. More...
 
 getRoot ()
 Get the base url for simple cache requests. More...
 
 registerCacheableView (string $view)
 Register a view as cacheable. More...
 
 isCacheableView (string $view)
 Is the view cacheable. More...
 
 getCacheableViews ()
 Returns the cacheable views. More...
 
 isEnabled ()
 Is simple cache enabled. More...
 
 enable ()
 Enables the simple cache. More...
 
 disable ()
 Disables the simple cache. More...
 
 clear ()
 Deletes all cached views in the simplecache. More...
 
 purge ()
 Purge old/stale cache content. More...
 
 cachedAssetExists (int $cache_time, string $viewtype, string $view)
 Check if a asset exists in the cache. More...
 
 getCachedAssetLocation (int $cache_time, string $viewtype, string $view)
 Get the cache location of an existing cached asset. More...
 
 cacheAsset (string $viewtype, string $view, string $contents)
 Store an asset for caching. More...
 

Protected Member Functions

 getPath ()
 Returns the path to where views are simplecached. More...
 
 getCacheFilename (string $viewtype, string $view, int $cache_time=null)
 Get the cache file location. More...
 

Protected Attributes

array $simplecache_views = []
 

Detailed Description

Simple cache service.

Definition at line 15 of file SimpleCache.php.

Constructor & Destructor Documentation

Elgg\Cache\SimpleCache::__construct ( protected Config  $config,
protected ViewsService  $views 
)

Constructor.

Parameters
Config$configElgg's global configuration
ViewsService$viewsViews service

Definition at line 30 of file SimpleCache.php.

Member Function Documentation

Elgg\Cache\SimpleCache::cacheAsset ( string  $viewtype,
string  $view,
string  $contents 
)

Store an asset for caching.

Parameters
string$viewtypeview type
string$viewview to cache
string$contentsview contents
Returns
int

Definition at line 253 of file SimpleCache.php.

Elgg\Cache\SimpleCache::cachedAssetExists ( int  $cache_time,
string  $viewtype,
string  $view 
)

Check if a asset exists in the cache.

Parameters
int$cache_timetime the asset was cached
string$viewtypeview type
string$viewcached view name
Returns
bool
Since
4.1

Definition at line 220 of file SimpleCache.php.

Elgg\Cache\SimpleCache::clear ( )

Deletes all cached views in the simplecache.

Returns
void
Since
3.3

Definition at line 178 of file SimpleCache.php.

Elgg\Cache\SimpleCache::disable ( )

Disables the simple cache.

Returns
void
See also
elgg_register_simplecache_view()

Definition at line 154 of file SimpleCache.php.

Elgg\Cache\SimpleCache::enable ( )

Enables the simple cache.

Returns
void
See also
elgg_register_simplecache_view()

Definition at line 144 of file SimpleCache.php.

Elgg\Cache\SimpleCache::getCacheableViews ( )

Returns the cacheable views.

Returns
array

Definition at line 125 of file SimpleCache.php.

Elgg\Cache\SimpleCache::getCachedAssetLocation ( int  $cache_time,
string  $viewtype,
string  $view 
)

Get the cache location of an existing cached asset.

Parameters
int$cache_timetime the asset was cached
string$viewtypeview type
string$viewcached view name
Returns
string|null null if asset doesn't exist
Since
4.1

Definition at line 236 of file SimpleCache.php.

Elgg\Cache\SimpleCache::getCacheFilename ( string  $viewtype,
string  $view,
int  $cache_time = null 
)
protected

Get the cache file location.

Parameters
string$viewtypeview type
string$viewcached view
int$cache_time(optional) cache time (default ->lastcache;
Returns
string

Definition at line 278 of file SimpleCache.php.

Elgg\Cache\SimpleCache::getPath ( )
protected

Returns the path to where views are simplecached.

Returns
string

Definition at line 167 of file SimpleCache.php.

Elgg\Cache\SimpleCache::getRoot ( )

Get the base url for simple cache requests.

Returns
string The simplecache root url for the current viewtype

Definition at line 61 of file SimpleCache.php.

Elgg\Cache\SimpleCache::getUrl ( string  $view)

Get the URL for the cached view.

$blog_js = $simpleCache->getUrl('blog/save_draft.js');
$favicon = $simpleCache->getUrl('graphics/favicon.ico');

This automatically registers the view with Elgg's simplecache.

Parameters
string$viewThe full view name
Returns
string

Definition at line 50 of file SimpleCache.php.

Elgg\Cache\SimpleCache::isCacheableView ( string  $view)

Is the view cacheable.

Parameters
string$viewthe view name
Returns
bool

Definition at line 90 of file SimpleCache.php.

Elgg\Cache\SimpleCache::isEnabled ( )

Is simple cache enabled.

Returns
bool

Definition at line 134 of file SimpleCache.php.

Elgg\Cache\SimpleCache::purge ( )

Purge old/stale cache content.

Returns
void

Definition at line 187 of file SimpleCache.php.

Elgg\Cache\SimpleCache::registerCacheableView ( string  $view)

Register a view as cacheable.

Parameters
string$viewthe view name
Returns
void

Definition at line 79 of file SimpleCache.php.

Member Data Documentation

array Elgg\Cache\SimpleCache::$simplecache_views = []
protected

Definition at line 22 of file SimpleCache.php.


The documentation for this class was generated from the following file: