You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sorl_kvstore.py 528B

1234567891011121314151617
  1. from django.core.cache import cache
  2. from sorl.thumbnail.conf import settings
  3. from sorl.thumbnail.kvstores.cached_db_kvstore import KVStore
  4. from sorl.thumbnail.models import KVStore as KVStoreModel
  5. class ConcurrentKVStore(KVStore):
  6. """
  7. Custom KV store for Sorl to avoid integrity errors when settings new
  8. values.
  9. """
  10. def _set_raw(self, key, value):
  11. KVStoreModel.objects.get_or_create(
  12. key=key, defaults={'value': value})
  13. cache.set(key, value, settings.THUMBNAIL_CACHE_TIMEOUT)