Skip to content

Commit e15e390

Browse files
committed
fix caching
1 parent e005388 commit e15e390

4 files changed

Lines changed: 76 additions & 6 deletions

File tree

modules/admin_manual/examples/installation/docker/docker-compose.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,18 @@ services:
8585
networks:
8686
- oc_network
8787

88+
# As alternative to Redis, you can enable Memcached.
89+
# See the caching configuration documentation for more details.
90+
91+
# memcached:
92+
# image: memcached:latest
93+
# container_name: owncloud_memcached
94+
# restart: always
95+
# ports:
96+
# - "11211:11211"
97+
# networks:
98+
# - oc_network
99+
88100
volumes:
89101
oc_files:
90102
driver: local

modules/admin_manual/pages/configuration/files/files_locking_transactional.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ ownCloud’s Transactional File Locking mechanism locks files to avoid file corr
1212
1313
Transactional File locking will not prevent multiple users from editing the same document, nor give notice that other users are working on the same document. Multiple users can open and edit a file at the same time and Transactional File locking does not prevent this. Rather, it prevents simultaneous file saving.
1414

15-
File locking is enabled by default, using the database locking backend. This places a significant load on your database. Using `memcache.locking` relieves the database load and improves performance. Admins of ownCloud servers with heavy workloads should install xref:configuration/server/caching_configuration.adoc[a memory cache] .
15+
File locking is enabled by default, using the database locking backend. This places a significant load on your database. Using `memcache.locking` (OWNCLOUD_MEMCACHE_LOCKING) relieves the database load and improves performance. Admins of ownCloud servers with heavy workloads should install a
16+
xref:configuration/server/caching_configuration.adoc[memory cache].

modules/admin_manual/pages/configuration/server/caching_configuration.adoc

Lines changed: 61 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@ The caching backends supported by ownCloud are:
3030
This is a data cache only and does *not* cache any opcode. APCu is part of the Docker image.
3131
* xref:redis[Redis] +
3232
This is an in-memory data structure store (cache) for single and multi-server ownCloud installations, which provides file locking and can be set up in local or distributed environments. The required `php-redis` extension is already part of the Docker image. Redis is used of the Docker Compose deployment example. For details see the xref:installation/installing_with_docker.adoc#docker-compose[Installing With Docker] documentation.
33+
* xref:memcached[Memcached] +
34+
This is a distributed cache for multi-server ownCloud installations and has *very limited* file locking capabilities. +
35+
Using Memcached for distributed locking is generally not recommended. Because its nodes do not communicate with each other and data isn't persistent, locks can be released unexpectedly or lost entirely if a server restarts. For reliable locking, Redis is the industry standard.
36+
+
37+
See the following page to learn more about the https://scalegrid.io/blog/redis-vs-memcached-2021-comparison/[Redis vs. Memcached – 2021 Comparison].
3338

3439
[NOTE]
3540
====
36-
You may use _both_ a local and a distributed cache. The recommended ownCloud caches are APCu and Redis. If you do not install and enable a local memory cache you will see a warning on your ownCloud admin page. If you enable only a distributed cache in your `config.php` (`memcache.distributed`) and not a local cache (`memcache.local`) you will still see the cache warning.
41+
You may use _both_ a local and a distributed cache. The recommended ownCloud caches are APCu and Redis. If you do not install and enable a local memory cache you will see a warning on your ownCloud admin page. If you either enable Redis or Memcached, the distributed cache will be set automatically to the respective backend.
3742
====
3843

3944
=== Cache Directory Location
@@ -97,13 +102,21 @@ NOTE: Out of the box, every Redis instance supports 16 databases so `<dbIndex>`
97102

98103
Please read more about the instructions for the {redis_select_url}[select] and {redis_flushdb_url}[flushdb] command.
99104

105+
=== Memcached
106+
107+
Memcached is a reliable old-timer for shared caching on distributed servers. It performs well with ownCloud with one exception: it is not suitable to use with Transactional File Locking. This is because it does not store locks, and data can disappear from the cache at any time. Given that, Redis is the best memory cache to use.
108+
109+
NOTE: The `memcached` PHP extension is already embedded in the Docker image and enabled.
110+
100111
== Configuring Memory Caching
101112

102113
Memory caches must be provided and explicitly configured in ownCloud by:
103114

104-
. When using Redis, it must be provided by either as described in the xref:installation/installing_with_docker.adoc#docker-compose[Docker Compose] example of the installation documentation or by other means.
115+
. When using Redis or Memcached, it must be provided by either as described in the xref:installation/installing_with_docker.adoc#docker-compose[Docker Compose] example of the installation documentation or by other means.
105116
. Configuring the caches used.
106117

118+
Note that the `OWNCLOUD_MEMCACHE_LOCKING` environment variable corresponds to the configuration setting `memcache.locking`. However, there is no counterpart for the setting `memcache.distributed`, as it is set automatically based on the caching type enabled.
119+
107120
See the
108121
xref:configuration/server/config_sample_php_parameters.adoc#memory-caching-backend-configuration[Memory caching backend configuration]
109122
for an overview of all possible config parameters, as the examples below only show basic configuration settings.
@@ -129,10 +142,11 @@ If you select Redis, you must enable it via environment variables. The example v
129142
----
130143
OWNCLOUD_REDIS_ENABLED=true
131144
OWNCLOUD_REDIS_HOST=redis
145+
OWNCLOUD_REDIS_PORT=6379
132146
----
133147

134148
* If Redis is not enabled, none of the other Redis configurations will be taken into account.
135-
* If Redis is enabled, two additional configurations are set automatically. Note that these configs are not configurable via environment variables:
149+
* If Redis is enabled, two additional configurations are set automatically:
136150
+
137151
--
138152
[source,.php]
@@ -151,9 +165,52 @@ OWNCLOUD_FILELOCKING_ENABLED=true
151165
OWNCLOUD_MEMCACHE_LOCAL='\OC\Memcache\Redis'
152166
----
153167

154-
155168
CAUTION: ownCloud provides many configuration options for Redis, including enhanced security features such as password protection. See the Redis security URL and the ownCloud environment variables for more details.
156169

170+
== Memcached Configuration
171+
172+
If you select Memcached, you must enable it via environment variables. The example value for the host setting assumes that you have used the ownCloud Docker Compose deployment example. Adapt this value for your setup.
173+
174+
[source,.env]
175+
----
176+
OWNCLOUD_MEMCACHED_ENABLED=true
177+
OWNCLOUD_MEMCACHED_HOST=memcached
178+
OWNCLOUD_MEMCACHED_PORT=11211
179+
----
180+
181+
////
182+
[NOTE]
183+
====
184+
If you are using multiple memcached servers, omit `OWNCLOUD_MEMCACHED_PORT` and use the following notation:
185+
186+
`OWNCLOUD_MEMCACHED_HOST="'host_1',port1,host_2',port_2"`
187+
====
188+
////
189+
190+
Additional memcached options can be set with the environment variable `OWNCLOUD_MEMCACHED_OPTIONS`.
191+
192+
* If Memcached is not enabled, none of the other Memcached configurations will be taken into account.
193+
* If Memcached is enabled, two additional configurations are set automatically:
194+
+
195+
--
196+
[source,.php]
197+
----
198+
'memcache.locking' => '\OC\Memcache\Memcached'
199+
'memcache.distributed' => '\OC\Memcache\Memcached'
200+
----
201+
--
202+
203+
=== Clearing the Memcached Cache
204+
205+
The Memcached cache can be flushed from the command line, using a range of common Linux/Unix tools including netcat and telnet. The following example uses telnet to log in, run the flush_all command, and log out:
206+
207+
[source,bash]
208+
----
209+
telnet <memcached-hostname> 11211
210+
flush_all
211+
quit
212+
----
213+
157214
== Deployment Type Configuration Examples
158215

159216
These examples provide an overview. Adapt them to suit your environment and needs.

modules/admin_manual/pages/configuration/server/config_sample_php_parameters.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1667,7 +1667,7 @@ Server details for one or more memcached servers to use for memory caching
16671667
....
16681668

16691669
=== Define connection options for memcached
1670-
For more details please see http://apprize.info/php/scaling/15.html
1670+
For more details please see https://www.php.net/manual/en/memcached.constants.php
16711671

16721672
==== Code Sample
16731673

0 commit comments

Comments
 (0)