You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Relay supports an adaptive caching mechanism to only cache keys that meet a read-write ratio to aid applications that suffer from cache thrashing, e.g. WordPress sites.
8
+
9
+
The configuration for the adaptive cache is highly individual to an application and should ideally be benchmarked. At the very least match the `width` of the cache to the unique number of keys that exist in the cache.
10
+
11
+
```php
12
+
$relay = new Relay(
13
+
host: 'localhost',
14
+
port: 6379,
15
+
context: [
16
+
'adaptive-cache' => [
17
+
// Number of horizontal cells. Ideally this should scale with the
18
+
// number of unique keys in the database. Supported values: 512 - 2^31.
19
+
'width' => 100_000,
20
+
21
+
// Number of vertical cells. Supported values: 1 - 8.
22
+
'depth' => 6,
23
+
24
+
// Minimum number of events (reads + writes) before Relay
25
+
// will use the ratio to determine if a key should remain cached.
26
+
// Using a negative number will invert this and Relay won't cache
27
+
// a key until its seen at least that many events for the key.
28
+
'minEvents' => 10,
29
+
30
+
// Minimum ratio of reads to writes of a key to remain
31
+
// cached (positive events) or be cached (negative events).
Copy file name to clipboardExpand all lines: docs/1.x/configuration.md
+2-1Lines changed: 2 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,13 +41,14 @@ To disable all in-memory caching and memory allocation `relay.maxmemory` can be
41
41
|`relay.locks.cache`|`mutex`| Locking mechanism used for the in-memory cache (databases). Supported values: `spinlock`, `mutex`, `adaptive-mutex`|
42
42
|`relay.default_pconnect`|`1`| Default to using a persistent connection when calling `connect()`. |
43
43
|`relay.initial_readers`|`128`| The number of epoch readers allocated on startup. |
44
-
|`relay.invalidation_poll_freq`|`5`| How often (in microseconds) Relay should proactively check the connection for invalidation messages from Redis. |
44
+
|`relay.invalidation_poll_freq`|`5`| How often (in microseconds) Relay should proactively check the connection for invalidation messages from Redis/Valkey. |
|`relay.logfile`|| The path to the file in which information should be logged, if logging is enabled. |
47
47
|`relay.cluster.seeds`|| The list of cluster nodes addresses grouped by cluster name, which will be used to initialize each cluster, encoded as URL query string, e.g. `cluster1[]=127.0.0.1:7000&cluster2[]=127.0.0.1:8000`|
48
48
|`relay.cluster.auth`|| The list of credentials for each cluster, encoded as URL query string. Password string or username/password pairs may be used, e.g. `cluster1=secret&cluster2[]=username&cluster2[]=secret`|
49
49
|`relay.cluster.timeout`|| The maximum number of seconds Relay will wait while establishing connection to a single cluster node. |
50
50
|`relay.cluster.read_timeout`|| The maximum number of seconds Relay will wait while reading from a cluster node. |
51
+
|`relay.cluster.slot_cache_expiry`|| The TTL of the cluster slot cache. |
51
52
|`relay.session.locking_enabled`|`0`| Whether to enable session locking to avoid race conditions and keep session data consistent across requests. |
52
53
|`relay.session.lock_expire`|`0`| The number of seconds while Relay will try to acquire lock. When value is zero or negative `max_execution_time` will be used. |
53
54
|`relay.session.lock_retries`|`0`| The number of attempts Relay will try to acquire lock. If value is zero or negative `100` will be used to be compatible with PhpRedis. |
Copy file name to clipboardExpand all lines: docs/1.x/connections.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ title: Connections
8
8
9
9
## Overview
10
10
11
-
Relay treats all connections as persistent by default, meaning each PHP worker will open its own dedicated connection to Redis and it will be reused between invocations.
11
+
Relay treats all connections as persistent by default, meaning each PHP worker will open its own dedicated connection to Redis/Valkey and it will be reused between invocations.
12
12
13
13
Establishing connections with Relay can be done just like using PhpRedis:
0 commit comments