(fmn) Use on-disk cache but in-memory lock
This commit is contained in:
parent
214410fde2
commit
a6d00b67c7
1 changed files with 26 additions and 0 deletions
|
@ -8,6 +8,31 @@ ircnick = "fedora-notifs"
|
||||||
|
|
||||||
base = "https://apps.%s/notifications/" % domain
|
base = "https://apps.%s/notifications/" % domain
|
||||||
|
|
||||||
|
from dogpile.core.readwrite_lock import ReadWriteMutex
|
||||||
|
from dogpile.cache.backends.file import AbstractFileLock
|
||||||
|
|
||||||
|
class MutexLock(AbstractFileLock):
|
||||||
|
""" Use an in-memory lock for our dogpile cache
|
||||||
|
in an attempt to reduce thread competition.
|
||||||
|
"""
|
||||||
|
def __init__(self, filename):
|
||||||
|
self.mutex = ReadWriteMutex()
|
||||||
|
|
||||||
|
def acquire_read_lock(self, wait):
|
||||||
|
ret = self.mutex.acquire_read_lock(wait)
|
||||||
|
return wait or ret
|
||||||
|
|
||||||
|
def acquire_write_lock(self, wait):
|
||||||
|
ret = self.mutex.acquire_write_lock(wait)
|
||||||
|
return wait or ret
|
||||||
|
|
||||||
|
def release_read_lock(self):
|
||||||
|
return self.mutex.release_read_lock()
|
||||||
|
|
||||||
|
def release_write_lock(self):
|
||||||
|
return self.mutex.release_write_lock()
|
||||||
|
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
{% if env == 'staging' %}
|
{% if env == 'staging' %}
|
||||||
# Pull in messages from production so we can more thoroughly test in stg.
|
# Pull in messages from production so we can more thoroughly test in stg.
|
||||||
|
@ -56,6 +81,7 @@ config = {
|
||||||
"expiration_time": 56700,
|
"expiration_time": 56700,
|
||||||
"arguments": {
|
"arguments": {
|
||||||
"filename": "/dev/shm/fmn-cache.dbm",
|
"filename": "/dev/shm/fmn-cache.dbm",
|
||||||
|
"lock_factory": MutexLock, # Use on-disk cache but in-memory lock.
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue