Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jovuit
funkwhale
Commits
b974568e
Verified
Commit
b974568e
authored
Oct 21, 2019
by
Eliot Berriot
Browse files
Added django-cacheops to cache expensive count queries
parent
cd07b196
Changes
2
Hide whitespace changes
Inline
Side-by-side
api/config/settings/common.py
View file @
b974568e
...
@@ -515,7 +515,6 @@ CACHES = {
...
@@ -515,7 +515,6 @@ CACHES = {
"LOCATION"
:
"local-cache"
,
"LOCATION"
:
"local-cache"
,
},
},
}
}
CACHES
[
"default"
][
"BACKEND"
]
=
"django_redis.cache.RedisCache"
CACHES
[
"default"
][
"BACKEND"
]
=
"django_redis.cache.RedisCache"
CHANNEL_LAYERS
=
{
CHANNEL_LAYERS
=
{
...
@@ -530,7 +529,20 @@ CACHES["default"]["OPTIONS"] = {
...
@@ -530,7 +529,20 @@ CACHES["default"]["OPTIONS"] = {
"IGNORE_EXCEPTIONS"
:
True
,
# mimics memcache behavior.
"IGNORE_EXCEPTIONS"
:
True
,
# mimics memcache behavior.
# http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior
# http://niwinz.github.io/django-redis/latest/#_memcached_exceptions_behavior
}
}
CACHEOPS_DURATION
=
env
(
"CACHEOPS_DURATION"
,
default
=
0
)
CACHEOPS_ENABLED
=
bool
(
CACHEOPS_DURATION
)
if
CACHEOPS_ENABLED
:
INSTALLED_APPS
+=
(
"cacheops"
,)
CACHEOPS_REDIS
=
env
(
"CACHE_URL"
,
default
=
CACHE_DEFAULT
)
CACHEOPS_PREFIX
=
lambda
_
:
"cacheops"
# noqa
CACHEOPS_DEFAULTS
=
{
"timeout"
:
CACHEOPS_DURATION
}
CACHEOPS
=
{
"users.user"
:
{
"ops"
:
"get"
},
"music.album"
:
{
"ops"
:
"count"
},
"music.artist"
:
{
"ops"
:
"count"
},
"music.track"
:
{
"ops"
:
"count"
},
}
# CELERY
# CELERY
INSTALLED_APPS
+=
(
"funkwhale_api.taskapp.celery.CeleryConfig"
,)
INSTALLED_APPS
+=
(
"funkwhale_api.taskapp.celery.CeleryConfig"
,)
...
...
api/requirements/base.txt
View file @
b974568e
...
@@ -72,3 +72,4 @@ django-oauth-toolkit==1.2
...
@@ -72,3 +72,4 @@ django-oauth-toolkit==1.2
django-storages==1.7.1
django-storages==1.7.1
boto3<3
boto3<3
unicode-slugify
unicode-slugify
django-cacheops==4.2
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment