Difference between revisions of "ARK2/Cache"

From ARK
Jump to: navigation, search
(Commands)
Line 35: Line 35:
 
* cache::refresh - clears and warmsup the System cache
 
* cache::refresh - clears and warmsup the System cache
 
* doctrine cache commands?
 
* doctrine cache commands?
 +
 +
Any cachable component should provide HTTP Kernel CacheWarmer and CacheClearer implementations and register these with the cache provider.

Revision as of 19:44, 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?

Any cachable component should provide HTTP Kernel CacheWarmer and CacheClearer implementations and register these with the cache provider.