Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the DJANGO_FSM_LOG_CACHE_TIMOUT parameter for `Cached… #126

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ article = Article.objects.get(...)
pending_state_log = StateLog.pending_objects.get_for_object(article)
```

### Debugging with `django_fsm_log.backends.CachedBackend` enabled

The `settings.DJANGO_FSM_LOG_CACHE_TIMOUT` parameter can be used to configure the cache timeout.
This can be usefull to avoid cache error when debugging transitions.

The default value is `10` seconds.

## Contributing

### Running tests
Expand Down
1 change: 1 addition & 0 deletions django_fsm_log/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ class DjangoFSMLogConf(AppConf):
STORAGE_METHOD = "django_fsm_log.backends.SimpleBackend"
CACHE_BACKEND = "default"
IGNORED_MODELS = []
CACHE_TIMEOUT = 10
2 changes: 1 addition & 1 deletion django_fsm_log/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def _get_cache_key_for_object(self, obj):
def create(self, *args, **kwargs):
log = self.model(**kwargs)
key = self._get_cache_key_for_object(kwargs["content_object"])
cache.set(key, log, 10)
cache.set(key, log, settings.DJANGO_FSM_LOG_CACHE_TIMEOUT)
return log

def commit_for_object(self, obj):
Expand Down