From e29d803abefbf15275a7dcdf0c82df9fdfc285d4 Mon Sep 17 00:00:00 2001 From: Azri Kahar <42867097+azrikahar@users.noreply.github.com> Date: Tue, 14 Sep 2021 00:48:26 +0800 Subject: [PATCH] Align memcached configurations for multiple hosts (#7986) * align memcached configurations for multiple hosts * update reference --- api/src/cache.ts | 7 ++++++- docs/reference/environment-variables.md | 18 +++++++++--------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/api/src/cache.ts b/api/src/cache.ts index 682bd5cf94..3371a6bed7 100644 --- a/api/src/cache.ts +++ b/api/src/cache.ts @@ -57,7 +57,12 @@ function getConfig(store: 'memory' | 'redis' | 'memcache' = 'memory', ttl: numbe if (store === 'memcache') { const KeyvMemcache = require('keyv-memcache'); - config.store = new KeyvMemcache(env.CACHE_MEMCACHE); + + // keyv-memcache uses memjs which only accepts a comma separated string instead of an array, + // so we need to join array into a string when applicable. See #7986 + const cacheMemcache = Array.isArray(env.CACHE_MEMCACHE) ? env.CACHE_MEMCACHE.join(',') : env.CACHE_MEMCACHE; + + config.store = new KeyvMemcache(cacheMemcache); } return config; diff --git a/docs/reference/environment-variables.md b/docs/reference/environment-variables.md index 8c5b8b3d4c..e361b91cd1 100644 --- a/docs/reference/environment-variables.md +++ b/docs/reference/environment-variables.md @@ -143,9 +143,9 @@ Alternatively, you can provide the individual connection parameters: ### Memcache -| Variable | Description | Default Value | -| ----------------------- | ---------------------------------- | ------------- | -| `RATE_LIMITER_MEMCACHE` | Location of your memcache instance | --- | +| Variable | Description | Default Value | +| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | +| `RATE_LIMITER_MEMCACHE` | Location of your memcache instance. You can use [`array:` syntax](#environment-syntax-prefix), eg: `array:,` for multiple memcache instances. | --- | ::: tip Additional Rate Limiter Variables @@ -191,9 +191,9 @@ Alternatively, you can provide the individual connection parameters: ### Memcache -| Variable | Description | Default Value | -| ---------------- | ---------------------------------- | ------------- | -| `CACHE_MEMCACHE` | Location of your memcache instance | --- | +| Variable | Description | Default Value | +| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | +| `CACHE_MEMCACHE` | Location of your memcache instance. You can use [`array:` syntax](#environment-syntax-prefix), eg: `array:,` for multiple memcache instances. | --- | ## Sessions @@ -225,9 +225,9 @@ Alternatively, you can provide the individual connection parameters: ### Memcache -| Variable | Description | Default Value | -| ------------------------ | ---------------------------------- | ------------- | -| `SESSION_MEMCACHE_HOSTS` | Location of your memcache instance | --- | +| Variable | Description | Default Value | +| ------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------- | +| `SESSION_MEMCACHE_HOSTS` | Location of your memcache instance. You can use [`array:` syntax](#environment-syntax-prefix), eg: `array:,` for multiple memcache instances. | --- | ### Database