From 83acc79f97e7b339cb11445b696477bd933b02dd Mon Sep 17 00:00:00 2001 From: TomJaeger Date: Mon, 2 Mar 2026 19:44:33 -0500 Subject: [PATCH] adding docs for the DB cache driver, as well as the send_ajax_response addition --- docs/development/legacy/libraries/cache.md | 8 ++++++-- docs/development/legacy/libraries/output.md | 17 ++++++++++++++--- docs/general/system-configuration-overrides.md | 5 +++++ docs/optimization/caching.md | 6 ++++-- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/docs/development/legacy/libraries/cache.md b/docs/development/legacy/libraries/cache.md index 21b76b06..b0917ec7 100755 --- a/docs/development/legacy/libraries/cache.md +++ b/docs/development/legacy/libraries/cache.md @@ -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. @@ -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(); diff --git a/docs/development/legacy/libraries/output.md b/docs/development/legacy/libraries/output.md index f2b5e5aa..24984da9 100755 --- a/docs/development/legacy/libraries/output.md +++ b/docs/development/legacy/libraries/output.md @@ -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: @@ -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')` @@ -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`. \ No newline at end of file +that variable names used in inline error handling can be more meaningful i.e. `field_name` instead of `field_id_1`. diff --git a/docs/general/system-configuration-overrides.md b/docs/general/system-configuration-overrides.md index 2f31913f..e577a1fc 100755 --- a/docs/general/system-configuration-overrides.md +++ b/docs/general/system-configuration-overrides.md @@ -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 | @@ -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). diff --git a/docs/optimization/caching.md b/docs/optimization/caching.md index b4e0cfa4..e14ea10f 100755 --- a/docs/optimization/caching.md +++ b/docs/optimization/caching.md @@ -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.