-
Notifications
You must be signed in to change notification settings - Fork 2
How do I change the cache locking type
See also: What is cache locking?
If you are experiencing rename() errors, or other PHP errors (PHP Exceptions) related to a race-condition; it could be attributed to file/directory locking. The concept of locking the cache directory and/or specific files in the cache directory is precisely what prevents race conditions and/or directory rename failures in Rapid Cache.
By default, Rapid Cache uses the popular flock strategy, as this works across the widest range of servers. Since flock requires no special PHP extensions to work effectively, it is the easiest way for Rapid Cache to accomplish file locking.
However, if your server supports sem_get() (see: http://php.net/manual/en/book.sem.php) you can tell Rapid Cache to use a Semaphore instead. On some hosting platforms, the use of flock() may not work as expected (e.g., if you use NFS or a server cluster). Therefore, if you are having trouble, please install the Semaphore extension for PHP, and then make the following change to your Rapid Cache installation.
Create this directory and file:
wp-content/mu-plugins/rc-cache-lock-type.php
<?php
add_filter('rapid_cache_cache_lock_type', function(){
return 'sem';
});