mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-08 08:08:13 +08:00
Upped version to 0.2.1
adds support for django-redis connections
This commit is contained in:
@@ -84,6 +84,9 @@ All configuration settings are optional. e.g:
|
|||||||
|
|
||||||
For full configuration options, see the `configuration documentation <http://django-q.readthedocs.org/en/latest/install.html#configuration>`__.
|
For full configuration options, see the `configuration documentation <http://django-q.readthedocs.org/en/latest/install.html#configuration>`__.
|
||||||
|
|
||||||
|
|
||||||
|
If you are using `django-redis <https://github.com/niwinz/django-redis>`__ , you can `configure Django Q <https://django-q.readthedocs.org/en/latest/install.html#django_redis>`__ to use its connection pool.
|
||||||
|
|
||||||
Management Commands
|
Management Commands
|
||||||
~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
from .tasks import async, schedule, result, fetch
|
from .tasks import async, schedule, result, fetch
|
||||||
from .models import Task, Schedule
|
from .models import Task, Schedule
|
||||||
|
|
||||||
VERSION = (0, 2, 0)
|
VERSION = (0, 2, 1)
|
||||||
|
|
||||||
default_app_config = 'django_q.apps.DjangoQConfig'
|
default_app_config = 'django_q.apps.DjangoQConfig'
|
||||||
|
|||||||
+19
-1
@@ -16,6 +16,10 @@ class Conf(object):
|
|||||||
# Redis server configuration . Follows standard redis keywords
|
# Redis server configuration . Follows standard redis keywords
|
||||||
REDIS = conf.get('redis', {})
|
REDIS = conf.get('redis', {})
|
||||||
|
|
||||||
|
# Support for Django-Redis connections
|
||||||
|
|
||||||
|
DJANGO_REDIS = conf.get('django_redis', None)
|
||||||
|
|
||||||
# Name of the cluster or site. For when you run multiple sites on one redis server
|
# Name of the cluster or site. For when you run multiple sites on one redis server
|
||||||
PREFIX = conf.get('name', 'default')
|
PREFIX = conf.get('name', 'default')
|
||||||
|
|
||||||
@@ -74,5 +78,19 @@ if not logger.handlers:
|
|||||||
handler.setFormatter(formatter)
|
handler.setFormatter(formatter)
|
||||||
logger.addHandler(handler)
|
logger.addHandler(handler)
|
||||||
|
|
||||||
|
|
||||||
|
# Django-redis support
|
||||||
|
if Conf.DJANGO_REDIS:
|
||||||
|
try:
|
||||||
|
import django_redis
|
||||||
|
except ImportError:
|
||||||
|
django_redis = None
|
||||||
|
|
||||||
|
|
||||||
|
def get_redis_client():
|
||||||
|
if Conf.DJANGO_REDIS and django_redis:
|
||||||
|
return django_redis.get_redis_connection(Conf.DJANGO_REDIS)
|
||||||
|
return redis.StrictRedis(**Conf.REDIS)
|
||||||
|
|
||||||
# redis client
|
# redis client
|
||||||
redis_client = redis.StrictRedis(**Conf.REDIS)
|
redis_client = get_redis_client()
|
||||||
|
|||||||
@@ -109,6 +109,21 @@ Connection settings for Redis. Defaults::
|
|||||||
|
|
||||||
For more information on these settings please refer to the `Redis-py <https://github.com/andymccurdy/redis-py>`__ documentation
|
For more information on these settings please refer to the `Redis-py <https://github.com/andymccurdy/redis-py>`__ documentation
|
||||||
|
|
||||||
|
django_redis
|
||||||
|
~~~~~~~~~~~~
|
||||||
|
|
||||||
|
If you are already using `django-redis <https://github.com/niwinz/django-redis>`__ for your caching, you can take advantage of its excellent connection backend by supplying the name
|
||||||
|
of the cache connection you want to use::
|
||||||
|
|
||||||
|
# example django-redis connection
|
||||||
|
Q_CLUSTER = {
|
||||||
|
'name': 'DJRedis',
|
||||||
|
'workers': 4,
|
||||||
|
'timeout': 90,
|
||||||
|
'django_redis: 'default'
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
.. tip::
|
.. tip::
|
||||||
Django Q uses your :const:`SECRET_KEY` to encrypt task packages and prevent task crossover. So make sure you have it set up in your Django settings.
|
Django Q uses your :const:`SECRET_KEY` to encrypt task packages and prevent task crossover. So make sure you have it set up in your Django settings.
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ class PyTest(Command):
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='django-q',
|
name='django-q',
|
||||||
version='0.2.0',
|
version='0.2.1',
|
||||||
author='Ilan Steemers',
|
author='Ilan Steemers',
|
||||||
author_email='koed00@gmail.com',
|
author_email='koed00@gmail.com',
|
||||||
packages=['django_q'],
|
packages=['django_q'],
|
||||||
|
|||||||
Reference in New Issue
Block a user