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

remove dbm, dyamodb, redis KVStores #760

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
strategy:
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
target: [pil, imagemagick, graphicsmagick, redis, wand, dbm]
target: [pil, imagemagick, graphicsmagick, wand]

include:
- python-version: '3.8'
Expand Down
115 changes: 0 additions & 115 deletions docs/reference/settings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,54 +25,6 @@ default one but just in case you would like to generate thumbnails filenames
differently or need some special functionality you can override this and use
your own implementation.


``THUMBNAIL_KVSTORE``
=====================

- Default: ``'sorl.thumbnail.kvstores.cached_db_kvstore.KVStore'``

sorl-thumbnail needs a Key Value Store to :doc:`/operation`.
sorl-thumbnail ships with support for three Key Value Stores:

Cached DB
---------
``sorl.thumbnail.kvstores.cached_db_kvstore.KVStore``. This is the default and
preferred Key Value Store.

Features
^^^^^^^^
* Fast persistent storage
* First query uses database which is slow. Successive queries are cached and if
you use memcached this is very fast.
* Easy to transfer data between environments since the data is in the default
database.
* If you get the database and fast cache out of sync there could be problems.

Redis
-----
``sorl.thumbnail.kvstores.redis_kvstore.KVStore``. It requires you to install a
Redis server as well as a `redis python client
<https://github.com/andymccurdy/redis-py/>`_.

Features
^^^^^^^^
* Fast persistent storage
* More dependencies
* Requires a little extra work to transfer data between environments

Dbm
---
``sorl.thumbnail.kvstores.dbm_kvstore.KVStore``. A simple Key Value Store has no
dependencies outside the standard Python library and uses the DBM modules to
store the data.

Features
^^^^^^^^
* No external dependencies, besides the standard library
* No extra components required, e.g., database or cache
* Specially indicated for local development environments


``THUMBNAIL_KEY_DBCOLUMN``
==========================

Expand Down Expand Up @@ -159,73 +111,6 @@ Only applicable for the convert Engine.
The storage class to use for the generated thumbnails.


``THUMBNAIL_REDIS_URL``
=======================

The Redis database URL to connect as used by `redis-py <https://redis-py.readthedocs.io/en/latest/#redis.Redis.from_url>`_

When specified, other ``THUMBNAIL_REDIS_*`` connection settings will be ignored.


``THUMBNAIL_REDIS_DB``
======================

- Default: ``0``

The Redis database. Only applicable for the Redis Key Value Store


``THUMBNAIL_REDIS_PASSWORD``
============================

- Default: ``''``

The password for Redis server. Only applicable for the Redis Key Value Store


``THUMBNAIL_REDIS_HOST``
========================

- Default: ``'localhost'``

The host for Redis server. Only applicable for the Redis Key Value Store


``THUMBNAIL_REDIS_PORT``
========================

- Default: ``6379``

The port for Redis server. Only applicable for the Redis Key Value Store


``THUMBNAIL_REDIS_TIMEOUT``
===========================

- Default: ``3600 * 24 * 365 * 10``

Cache timeout for Redis Key Value Store in seconds. You should probably keep this
at maximum or ``None``.


``THUMBNAIL_DBM_FILE``
======================

- Default: ``thumbnail_kvstore``

Filename of the DBM database. Depending on the DBM engine selected by your
Python installation, this will be used as a prefix because multiple files may be
created. This can be an absolute path.


``THUMBNAIL_DBM_MODE``
======================

- Default: ``0x644``

Permission bits to use when creating new DBM files


``THUMBNAIL_CACHE_TIMEOUT``
===========================

Expand Down
19 changes: 0 additions & 19 deletions sorl/thumbnail/conf/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
# Backend
THUMBNAIL_BACKEND = 'sorl.thumbnail.base.ThumbnailBackend'

# Key-value store, ships with:
# sorl.thumbnail.kvstores.cached_db_kvstore.KVStore
# sorl.thumbnail.kvstores.redis_kvstore.KVStore
# Redis requires some more work, see docs
THUMBNAIL_KVSTORE = 'sorl.thumbnail.kvstores.cached_db_kvstore.KVStore'

# Change this to something else for MSSQL
THUMBNAIL_KEY_DBCOLUMN = 'key'

Expand All @@ -33,19 +27,6 @@
# Storage for the generated thumbnails
THUMBNAIL_STORAGE = settings.STORAGES['default']['BACKEND']

# Redis settings
THUMBNAIL_REDIS_DB = 0
THUMBNAIL_REDIS_PASSWORD = ''
THUMBNAIL_REDIS_HOST = 'localhost'
THUMBNAIL_REDIS_PORT = 6379
THUMBNAIL_REDIS_UNIX_SOCKET_PATH = None
THUMBNAIL_REDIS_SSL = False
THUMBNAIL_REDIS_TIMEOUT = 3600 * 24 * 365 * 10 # 10 years

# DBM settings
THUMBNAIL_DBM_FILE = "thumbnail_kvstore"
THUMBNAIL_DBM_MODE = 0o644

# Cache timeout for ``cached_db`` store. You should probably keep this at
# maximum or ``0`` if your caching backend can handle that as infinite.
THUMBNAIL_CACHE_TIMEOUT = 3600 * 24 * 365 * 10 # 10 years
Expand Down
5 changes: 2 additions & 3 deletions sorl/thumbnail/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@ class Backend(LazyObject):
def _setup(self):
self._wrapped = get_module_class(settings.THUMBNAIL_BACKEND)()


class KVStore(LazyObject):
def _setup(self):
self._wrapped = get_module_class(settings.THUMBNAIL_KVSTORE)()
def _setup(self):
self._wrapped = get_module_class("sorl.thumbnail.kvstores.cached_db_kvstore.KVStore")()


class Engine(LazyObject):
Expand Down
93 changes: 0 additions & 93 deletions sorl/thumbnail/kvstores/dbm_kvstore.py

This file was deleted.

37 changes: 0 additions & 37 deletions sorl/thumbnail/kvstores/dynamodb_kvstore.py

This file was deleted.

36 changes: 0 additions & 36 deletions sorl/thumbnail/kvstores/redis_kvstore.py

This file was deleted.

4 changes: 0 additions & 4 deletions tests/settings/dbm.py

This file was deleted.

2 changes: 0 additions & 2 deletions tests/settings/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
'class': 'sorl.thumbnail.log.ThumbnailLogHandler',
'level': 'ERROR',
}
THUMBNAIL_KVSTORE = 'tests.thumbnail_tests.kvstore.TestKVStore'
THUMBNAIL_STORAGE = 'tests.thumbnail_tests.storage.TestStorage'
STORAGES = {
"default": {
Expand Down Expand Up @@ -51,4 +50,3 @@
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
THUMBNAIL_REDIS_SSL = False
8 changes: 0 additions & 8 deletions tests/settings/dynamodb.py

This file was deleted.

4 changes: 0 additions & 4 deletions tests/settings/redis.py

This file was deleted.

Loading
Loading