APCu cache folder empty

Nextcloud version (eg, 20.0.5): 26.0.1
Operating system and version (eg, Ubuntu 20.04): Ubuntu Server 22.04.2 LTS
Apache or nginx version (eg, Apache 2.4.25): Apache 2.4.52
PHP version (eg, 7.4): 8.1.2

The issue you are facing:
Trying to set up APCu for data caching. I have it installed (php-apcu) on the server. Even after enabling it, the cache folder remains empty for all users regardless of accessed files.

Is this the first time you’ve seen this error? (Y/N): Y

Steps to replicate it:

  1. In the config.php file /var/www/nextcloud/config/config.php add the following two lines 'memcache.local' => '\OC\Memcache\APCu', and 'cache_path' => '/mnt/ssd100/nextCloudCache',
  2. Create the folder /mnt/ssd100/nextCloudCache and execute the following command sudo chown -R www-data:www-data /mnt/ssd100/nextCloudCache for nextcloud to be able to access the folder
  3. In the file /etc/php/8.1/mods-available/apcu.ini add the following line apc.enable_cli=1. The only other line in that file is the line above: extension=apcu.so .
  4. The output of the command sudo ls -l /mnt/ssd100/nextCloudCache/Nemanja is total 0. It can be observed that the folder Nemanja has been created when accessing the files from the user Nemanja, but nothing is cached.

The output of your Nextcloud log in Admin > Logging:

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

The output of your Apache/nginx/system log in /var/log/____:
error.log

PASTE HERE


Output errors in nextcloud.log in /var/www/ or as admin user in top right menu, filtering for errors. Use a pastebin service if necessary.

PASTE HERE

Hi,

apcu and cache_path are not related.

2 Likes

Hi @kesselb,

I was following the instructions given in the documentation below:
Memory caching — Nextcloud latest Administration Manual latest documentation

Under the very last section of that documentation file called Cache Directory location it states the following:

The cache directory defaults to data/$user/cache where $user is the current user. You may use the 'cache_path' directive in config.php (See Configuration Parameters) to select a different location.

The Configuration Parameters page further states that

When [cache_path is] specified, the format will change to $cache_path/$user where $cache_path is the configured cache directory and $user is the user.

All that would imply that cache_path does indeed refer to APCu cache folder location… I am in fact seeing that the $cache_path is being used and that the $user folders are created, but nothing is written inside them.

Is it really not the case that the cache_path is used for APCu? If not, is there a way to move the cache folder of APCu to the path given in the config.php file attached in the first post?

APCu is an in-memory key-value store for PHP and does not store nothing on disks.

If you look at the initialing of the manual you would see that the cashe directory has nothing to do with ACPu:

image

That does not say nothing! Those folders are created when a new location is defined (as in your case). Here the function that does that.

But you’ve probably created an additional bottleneck, since it’s much faster to move finished cashed content to the user directory than to copy it.

1 Like

@ernolf Ah, thank you so much for the clarification.
A question based on your reply (sorry, I’m still learning). Is the cache_path then used just for upload (upload files first to cache, then move them to the data drive once they are uploaded)? If so, then I totally understand the part :

If so, does cache_path then reffer to opcache from the php.ini file?

That is what I would expect.
But there is the uploads folder as well beside the cache folder.

I am just a user as you and did never monitor the exact usage of those folders but I noticed, that the music app uses the cache folder for a file caled music_collection.json.

Much luck

1 Like

Ok, for completeness sake, I’m writing the preliminary results of the findings from this thread.

  1. In most cases, there is no need to change the cache_path parameter since it is mostly used for upload and other Nextcloud specific caching.
  2. cache_path has nothing to do with APCu. APCu works completely automatically and is in-memory (RAM) as can be seen in the official documentation of it here. That means that other than enabling it, no further configuration is strictly needed for it to work.
  3. I’ve changed my configuration since the post has been created two times. First time I removed the cache_path parameter from the config.php since moving it anywhere else than the disk would introduce bottleneck to the upload process since copying from the location to the data location would be needed.
    After thinking about it, I created a RAM disk for the cache folder since that wouldn’t create a bottleneck.
    The way I have it set up now is:
    • Create a mountpoint for the RAM disk. For the example, I will create a 12 GB RAM disk and name it ramdisk12. The command for creating a mountpoint is
        sudo mkdir /media/ramdisk12
  • Create an entry in /etc/fstab to create the RAM disk at system startup and mount it to /media/ramdisk12. For this, the following line is added to etc/fstab:
        tmpfs /media/ramdisk12 tmpfs rw,nodev,nosuid,size=12G 0 0
  • Add the following line to the config.php for the Nextcloud instance:
        'cache_path' => '/media/ramdisk12/nextcloud_cache',
  1. :question:Still not fully resolved for which exactly cache the cache_path is used and needs further investigation… (…or hints from the community…) The main thing that is confusing me is that it seems to be used as a temporary upload location. But according to this part of the documentation:
    Uploading big files > 512MB — Nextcloud latest Administration Manual latest documentation, it can be seen in the System configuration section that the uploads are stored in “the temp file or partition” since it “has to be big enough to hold multiple parallel uploads from multiple users” and that is already set to ramdisk12 as in this example and not in the data/$user/cache as stated that as the default value of cache_path as seen in this part of the documentation:
    Configuration Parameters → cache_path — Nextcloud latest Administration Manual latest documentation