Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The Readme file states that "Locks have not yet been implemented using the memcache module.".
The Readme file also says about "Stampede Protection": "To avoid lock stampedes, it is important that you enable the memcache lock implementation when enabling stampede protection..."
But the lock implemetation seems to work file - I added this to my services.yml to enable the feature:
services:
# Replaces the default lock backend with a memcache implementation.
lock:
class: Drupal\Core\Lock\LockBackendInterface
factory: ['@memcache.lock.factory', get]
# Replaces the default persistent lock backend with a memcache implementation.
lock.persistent:
class: Drupal\Core\Lock\LockBackendInterface
factory: ['@memcache.lock.factory', get]
arguments: [true]
If someone who knows more about this than myself can confirm that the locking backend fully works it should be added to the documentation.
Comment | File | Size | Author |
---|---|---|---|
#11 | interdiff-2852460-9.txt | 722 bytes | damiankloip |
#7 | document_locking_backend-2852460-7.patch | 773 bytes | kalpaitch |
Comments
Comment #2
j.b CreditAttribution: j.b commentedHi vurt,
How did you manage to get it working ?
You created a custom module and a corresponding services.yml ?
Then did you add something in the settings.php ?
I urgently need the locking system to be managed by memcached.
I have a live website with quite huge traffic and we are noticing frequent deadlocks related to the cache.
Comment #3
vurt CreditAttribution: vurt as a volunteer and at Computer Manufaktur GmbH commentedI just added the configuration to sites/default/services.yml, just like I wrote.
Have you enabled and configured the memcache module? Then you should not see database deadlocks on the cache tables. The (optional) memcache locking implementation only helps against deadlocks on the semaphore table.
Comment #4
j.b CreditAttribution: j.b commentedThanks,
It works.
Comment #5
bkosborneThis works but the code snippet needs to be updated. Looks like it was copied from the Redis module's implementation.
Comment #6
vurt CreditAttribution: vurt as a volunteer and at Computer Manufaktur GmbH commentedThank you very much for the correction! Yes this was from a Redis example because I could not find anything about Memcache and locking for Drupal 8.
And thank you very much for confirming that it works.
I double-checked if this is working by putting some debug output in the aquire() and release() functions. It really works.
Comment #7
kalpaitch CreditAttribution: kalpaitch as a volunteer and commentedIf the lock is present let's support it.
Comment #8
kalpaitch CreditAttribution: kalpaitch as a volunteer and commentedComment #10
damiankloip CreditAttribution: damiankloip commentedThis is not correct for memcache, the method is
getPersistent
. So #5 is correct. See attached interdiff. Committed and pushed with this. Thanks!Comment #11
damiankloip CreditAttribution: damiankloip commentedComment #13
vorapoap CreditAttribution: vorapoap as a volunteer commentedI think the document should update to include the services.yml file in this way to avoid the .... The service "lock" has a dependency on a non-existent service "memcache.lock.factory". ..... issue.
https://docs.acquia.com/acquia-cloud/performance/memcached/locks/