Skip to content

Commit

Permalink
github/workflows: adds redis service for testing cache
Browse files Browse the repository at this point in the history
  • Loading branch information
hklarner committed Oct 10, 2023
1 parent 87bfde8 commit 81b76c4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ charset = utf-8
indent_style = space
indent_size = 4

[*.{js,jsx,json}]
[*.{js,jsx,json,yml}]
indent_size = 2

[Makefile]
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ jobs:
--health-interval 10s
--health-timeout 5s
--health-retries 5
redis:
image: redis
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand Down Expand Up @@ -60,7 +69,7 @@ jobs:
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: check a4 hashes equal
- name: Check a4 hashes equal
run: |
./scripts/a4-check.sh
- name: Install Dependencies
Expand Down
6 changes: 4 additions & 2 deletions docs/caching.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,10 @@ The name space for each API endpoint is hard-coded and prefixed by a global cach
- `api_cache_projectcontainers`
- `api_cache_plans`

In production, we use redis as cache backend (`django_redis.cache.RedisCache`, see `settings/production.py::CACHES`). For development the cache backend is disabled (see `settings/base.py::CACHES`). If you want to enable it locally, then copy the production settings to your `settings/local.py`.
In production, we use redis as cache backend (`django_redis.cache.RedisCache`, see `settings/production.py::CACHES`). For development the cache backend is disabled (undefined). If you want to enable it locally, then copy the production settings to your `settings/local.py`.

All tests that relate to caching are conditional. If the redis caching backend is not detected (see `caching.py::REDIS_IS_ENABLED`) then tests are skiped.

Some more notes about the caching module:
- it is indented to be imported as a module instead of importing individual methods so that you call `caching.add_or_query(..)` instead of `add_or_query(..)`, for example
- it is intended to be imported as a module instead of importing individual methods (e.g. you call `caching.add_or_query(..)` instead of `add_or_query(..)`)
- `caching.delete(..)` can either be given a namespace or an explicit list of keys to be deleted and returns all keys that were deleted

0 comments on commit 81b76c4

Please sign in to comment.