Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions docs/development/legacy/libraries/cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ lang: php

[TOC]

ExpressionEngine's Cache Class gives developers easy ways to cache data (strings, arrays, objects) in a key-value store. The storage driver can be either file-based or memory-based. More about supported drivers and configuration can be found under [Data Caching and Performance](optimization/caching.md#caching-drivers).
ExpressionEngine's Cache Class gives developers easy ways to cache data (strings, arrays, objects) in a key-value store. The storage driver can be file-based, database-backed, or memory-based. More about supported drivers and configuration can be found under [Data Caching and Performance](optimization/caching.md#caching-drivers).

Unlike the [Session Cache](development/legacy/libraries/session.md#cache-access), items stored using the Cache class can persist across multiple page loads because cache items are either stored on disk or in a memory-based cache store not dependent on ExpressionEngine.
Unlike the [Session Cache](development/legacy/libraries/session.md#cache-access), items stored using the Cache class can persist across multiple page loads because cache items are stored on disk, in the database, or in a memory-based cache store not dependent on ExpressionEngine.

It's highly recommended you use the Cache Class when possible instead of manually writing to a cache directory so that cache items can be easily managed and seamlessly moved to a memory-based cache store so those with high traffic or network file systems can take advantage of the speed and versatility a memory-based cache offers and not be bogged down by file locks and I/O limitations on the disk.

Expand Down Expand Up @@ -149,3 +149,7 @@ Returns metadata about a particular item in the cache:
Checks to see if appropriate extensions and resources are available for a driver to determine if it is usable for caching:

ee()->cache->memcached->is_supported();

You can also check database driver support:

ee()->cache->database->is_supported();
17 changes: 14 additions & 3 deletions docs/development/legacy/libraries/output.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,12 @@ NOTE: **Note:** Calling this method manually without aborting script execution w
| Parameter | Type | Description |
| --------- | -------- | -------------------- |
| \$msg | `Array` | Object to be sent to the client. |
| \$error | `Bool|Int` | HTTP status code. If `false`, status code is `200`. If `true`, status code is 500 |
| \$statusCode | `Bool|Int` | HTTP status code. If `false`, status code is `200`. If `true`, status code is 500 |
| Returns | `Void` | void |

Calling this method encode the given `$msg` parameter and will set the header `Content-Type: application/json`.
Calling this method encodes the given `$msg` parameter and sets the header `Content-Type: application/json`.

Any headers previously set with `set_header()` are also sent with the AJAX response.

Example:

Expand Down Expand Up @@ -195,6 +197,15 @@ $output = array(
'message' => 'not allowed',
);
ee()->output->send_ajax_response($output, true);
```

With a custom response header:

```php
ee()->output
->set_header('X-Example: value')
->send_ajax_response(['success' => true], 200);
```

### `show_message($data, $xhtml = true, $redirect_url = false, $template_name = 'generic')`

Expand Down Expand Up @@ -269,4 +280,4 @@ appropriate template.
| Returns | `Void` | void |

This function builds upon `show_form_error()` with the additional ability to provide aliases for input names so
that variable names used in inline error handling can be more meaningful i.e. `field_name` instead of `field_id_1`.
that variable names used in inline error handling can be more meaningful i.e. `field_name` instead of `field_id_1`.
5 changes: 5 additions & 0 deletions docs/general/system-configuration-overrides.md
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ Specify a different [caching driver](optimization/caching.md#caching-drivers) to
| Values | Description |
| --------- | -------------------------------------------------- |
| file | File driver, /system/user/cache/ (default) |
| database | Database driver, stores cache in `exp_cache` |
| memcached | Memcached driver, configured with memcached config |
| redis | Redis driver, configured with redis config |
| dummy | Dummy driver, will not cache |
Expand All @@ -519,6 +520,10 @@ Example Usage:

$config['cache_driver'] = 'memcached';

Database-backed caching is also available:

$config['cache_driver'] = 'database';

## `cache_driver_backup`

Specify a backup [caching driver](optimization/caching.md#caching-drivers) to use in case the one specified in [cache_driver](#cache_driver) isn't available. Same values accepted and same default as [cache_driver](#cache_driver).
Expand Down
6 changes: 4 additions & 2 deletions docs/optimization/caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,11 @@ You can also use disable="category_fields" in the [channel categories](channels/

**Control Panel Location:** `Settings --> Debugging & Output`

By default, ExpressionEngine uses a file-based caching driver, meaning cached items are written to disk. This is the most-compatible option for all servers and works well in most cases. However, the traffic on your site may reach a point where the file-based caching becomes a bottleneck due to disk I/O, or may cause issues in some Network File System instances, in which case you may want to use a memory-based caching driver.
By default, ExpressionEngine uses a file-based caching driver, meaning cached items are written to disk. This is the most-compatible option for all servers and works well in most cases. However, the traffic on your site may reach a point where file-based caching becomes a bottleneck due to disk I/O, or may cause issues in some Network File System instances.

ExpressionEngine currently supports Memcached and Redis for memory-based caching. You can set which driver is being used in the control panel or via the [cache_driver](general/system-configuration-overrides.md#cache_driver) config override. [Memcached](general/system-configuration-overrides.md#memcached) and [Redis](general/system-configuration-overrides.md#redis) server information can also be set in `config.php`, otherwise ExpressionEngine will try to connect to the default respective ports on localhost.
ExpressionEngine also supports database, Memcached, and Redis caching drivers. You can set which driver is being used in the control panel or via the [cache_driver](general/system-configuration-overrides.md#cache_driver) config override. [Memcached](general/system-configuration-overrides.md#memcached) and [Redis](general/system-configuration-overrides.md#redis) server information can also be set in `config.php`, otherwise ExpressionEngine will try to connect to the default respective ports on localhost.

The database driver stores cache rows in `exp_cache`, which can reduce filesystem I/O but adds read/write load to your database server. For higher-throughput workloads, Memcached or Redis are generally better choices.

A [backup driver](general/system-configuration-overrides.md#cache_driver_backup) can also be specified in the case your primary driver is unavailable. By default, the backup driver is the file driver and it's likely the best failover option due to its reliability, but the backup driver is configurable.

Expand Down