Difference between revisions of "ARK2/Cache"

From ARK
Jump to: navigation, search
(Implementation)
Line 18: Line 18:
  
 
Two caches are provided, the System and Application caches:
 
Two caches are provided, the System and Application caches:
* System: Not persistent, not distributed
+
* System: Not persistent, not distributed, intended for static config, metadata, etc
* App: Persistent, Distributed
+
* App: Persistent, Distributed,
 +
 
 +
These caches are accessed via the container:
 +
* $app['cache.app'] or $app['cache']
 +
* $app['cache.system']
 +
* $app['cache.orm.app']
 +
* $app['cache.orm.system']
 +
 
 +
The Service object also provides access to the
  
 
== Commands ==
 
== Commands ==
  
Warmup, Clear, Status, etc
+
* cache::warmup - warms-up the System cache
 +
* cache::clear - clears the System cache
 +
* cache::refresh - clears and warmsup the System cache
 +
* doctrine cache commands?

Revision as of 16:38, 27 December 2016

Cache

Caching can greatly improve performance of ARK, especially for configuration and metadata, but also the data and database access. ARK provides a flexible caching system based on Doctrine Cache, Symphony Cache, and the PSR-6 Caching standard, and supporting filesystem, APCu, or Redis caches (others are possible but not officially supported).

By default, ARK will use APCu for caching if your server has APCu installed, otherwise a filesystem cache will be used. For high-volume sites and APIs, Redis is recommended using either Predis or PHPRedis. Redis can also be used as a Spatial cache to speed up spatial searches.

Configuration

If caching is not explicitly configured in the site.json file, then ARK will check if APCu is available, and if not will fall back to the filesystem. To fractionally improve performance, you can use site.json to explicitly set 'apcu' or 'file'.

If using Redis you need to explicitly set site.json to use 'redis' and the url of the Redis instance.

If Debug mode is enabled, the the cache is disabled.

Implementation

The Doctrine ORM requires the use of the Doctrine Cache component to cache database access, however it is not PSR-6 compliant and is primarily designed for database caching. The Symfony Cache component provides a PSR-6 implementation designed for a wider use case, and provides a bridge to the Doctrine Cache. ARK creates a Doctrine Cache object which is then passed to the Symfony Cache.

Two caches are provided, the System and Application caches:

  • System: Not persistent, not distributed, intended for static config, metadata, etc
  • App: Persistent, Distributed,

These caches are accessed via the container:

  • $app['cache.app'] or $app['cache']
  • $app['cache.system']
  • $app['cache.orm.app']
  • $app['cache.orm.system']

The Service object also provides access to the

Commands

  • cache::warmup - warms-up the System cache
  • cache::clear - clears the System cache
  • cache::refresh - clears and warmsup the System cache
  • doctrine cache commands?