Skip to content
Snippets Groups Projects
Commit f1be7567 authored by Vermaat's avatar Vermaat
Browse files

Talking to a Redis server

parent 98bef8cc
No related branches found
No related tags found
No related merge requests found
...@@ -26,7 +26,12 @@ MAX_CACHE_SIZE = 50 * 1048576 # 50 MB ...@@ -26,7 +26,12 @@ MAX_CACHE_SIZE = 50 * 1048576 # 50 MB
# Maximum size for uploaded and downloaded files (in bytes). # Maximum size for uploaded and downloaded files (in bytes).
MAX_FILE_SIZE = 10 * 1048576 # 10 MB MAX_FILE_SIZE = 10 * 1048576 # 10 MB
# Database connection URL (can be any SQLAlchemy connection URI). # Redis connection URI (can be any redis-py connection URI). Redis is used
# for keeping statistics counters. Setting this to `None`, will silently
# yield a mock Redis.
REDIS_URI = None
# Database connection URI (can be any SQLAlchemy connection URI).
DATABASE_URI = 'sqlite://' DATABASE_URI = 'sqlite://'
# Host name for local MySQL databases. # Host name for local MySQL databases.
......
"""
Lazy global interface to Redis.
Redis connections can safely be shared among threads, so we can keep this very
simple and just use one global connection pool as created by `StrictRedis`.
.. note:: Redis is only used for non-essential features in Mutalyzer and
therefore a Redis server is not a hard requirement to run Mutalyzer.
If the `REDIS_URI` configuration setting is `None`, we silently
instantiate a mock interface to Redis.
"""
import redis
from mutalyzer import settings
from mutalyzer import util
class LazyClient(util.LazyObject):
"""
A lazy proxy for a `StrictRedis` object.
"""
def _setup(self):
"""
Instantiate the Redis interface. This called the first time Redis is
used.
"""
if settings.REDIS_URI is None:
import mockredis
self._wrapped = mockredis.MockRedis(strict=True)
else:
self._wrapped = redis.StrictRedis.from_url(settings.REDIS_URI)
client = LazyCLient()
...@@ -18,3 +18,5 @@ Jinja2==2.7.1 ...@@ -18,3 +18,5 @@ Jinja2==2.7.1
-e git+https://github.com/mammadori/magic-python.git#egg=Magic_file_extensions -e git+https://github.com/mammadori/magic-python.git#egg=Magic_file_extensions
Flask==0.10.1 Flask==0.10.1
https://bitbucket.org/zzzeek/sqlalchemy/downloads/SQLAlchemy-0.9.0b1.tar.gz https://bitbucket.org/zzzeek/sqlalchemy/downloads/SQLAlchemy-0.9.0b1.tar.gz
redis==2.8.0
mockredispy==2.8.0.2
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment