Fix #117: Use django-cacheops to cache common ORM requests
This commit is contained in:
parent
c70ab72bc0
commit
a448eaaf17
|
@ -23,6 +23,8 @@ test_api:
|
||||||
DJANGO_ALLOWED_HOSTS: "localhost"
|
DJANGO_ALLOWED_HOSTS: "localhost"
|
||||||
DATABASE_URL: "postgresql://postgres@postgres/postgres"
|
DATABASE_URL: "postgresql://postgres@postgres/postgres"
|
||||||
FUNKWHALE_URL: "https://funkwhale.ci"
|
FUNKWHALE_URL: "https://funkwhale.ci"
|
||||||
|
CACHEOPS_ENABLED: "false"
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- cd api
|
- cd api
|
||||||
- pip install -r requirements/base.txt
|
- pip install -r requirements/base.txt
|
||||||
|
|
|
@ -60,6 +60,7 @@ THIRD_PARTY_APPS = (
|
||||||
'mptt',
|
'mptt',
|
||||||
'dynamic_preferences',
|
'dynamic_preferences',
|
||||||
'django_filters',
|
'django_filters',
|
||||||
|
'cacheops',
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@ -369,6 +370,15 @@ MUSICBRAINZ_CACHE_DURATION = env.int(
|
||||||
'MUSICBRAINZ_CACHE_DURATION',
|
'MUSICBRAINZ_CACHE_DURATION',
|
||||||
default=300
|
default=300
|
||||||
)
|
)
|
||||||
|
CACHEOPS_REDIS = env('CACHE_URL', default=CACHE_DEFAULT)
|
||||||
|
CACHEOPS_ENABLED = env.bool('CACHEOPS_ENABLED', default=True)
|
||||||
|
CACHEOPS = {
|
||||||
|
'music.artist': {'ops': 'all', 'timeout': 60 * 60},
|
||||||
|
'music.album': {'ops': 'all', 'timeout': 60 * 60},
|
||||||
|
'music.track': {'ops': 'all', 'timeout': 60 * 60},
|
||||||
|
'music.trackfile': {'ops': 'all', 'timeout': 60 * 60},
|
||||||
|
'taggit.tag': {'ops': 'all', 'timeout': 60 * 60},
|
||||||
|
}
|
||||||
|
|
||||||
# Custom Admin URL, use {% url 'admin:index' %}
|
# Custom Admin URL, use {% url 'admin:index' %}
|
||||||
ADMIN_URL = env('DJANGO_ADMIN_URL', default='^api/admin/')
|
ADMIN_URL = env('DJANGO_ADMIN_URL', default='^api/admin/')
|
||||||
|
|
|
@ -58,3 +58,4 @@ python-magic==0.4.15
|
||||||
ffmpeg-python==0.1.10
|
ffmpeg-python==0.1.10
|
||||||
channels>=2,<2.1
|
channels>=2,<2.1
|
||||||
channels_redis>=2.1,<2.2
|
channels_redis>=2.1,<2.2
|
||||||
|
django-cacheops>=4,<4.1
|
||||||
|
|
|
@ -13,5 +13,6 @@ services:
|
||||||
- "DJANGO_ALLOWED_HOSTS=localhost"
|
- "DJANGO_ALLOWED_HOSTS=localhost"
|
||||||
- "DATABASE_URL=postgresql://postgres@postgres/postgres"
|
- "DATABASE_URL=postgresql://postgres@postgres/postgres"
|
||||||
- "FUNKWHALE_URL=https://funkwhale.test"
|
- "FUNKWHALE_URL=https://funkwhale.test"
|
||||||
|
- "CACHEOPS_ENABLED=False"
|
||||||
postgres:
|
postgres:
|
||||||
image: postgres
|
image: postgres
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Use django-cacheops to cache common ORM requests (#117)
|
Loading…
Reference in New Issue