def setup_database(config, logger): if config["embedded"]: connection_setup() db = get_client() db.flushall() return db dbhost = config["dbhost"] dbport = config["dbport"] logger.debug( "Waiting for Redis Service on {0:s}:{1:d} ...".format(dbhost, dbport) ) waitfor(dbhost, dbport) logger.debug( "Connecting to Redis on {0:s}:{1:d} ...".format(dbhost, dbport) ) connection_setup(host=dbhost, port=dbport) logger.debug("Success!") db = get_client() db.flushall() return db
def __init__(self): self.channel = 'GLOBALSIGNALS' self.workers = defaultdict(set) self.rc = redisco.get_client() self.ps = self.rc.pubsub() self.ps.subscribe(self.channel) self.funcnames = set() gevent.spawn(self._listener)
def __init__(self, model_class): self.model_class = model_class self.key = model_class._key['all'] self._db = redisco.get_client() self._filters = {} self._exclusions = {} self._zfilters = [] self._ordering = [] self._limit = None self._offset = None
def setUp(self): """Before each test, set up a blank database""" gplab.app.config["TESTING"] = True gplab.app.config["CSRF_ENABLED"] = False connection_setup(host="localhost", port=6379, db=4) client = get_client() client.flushdb() self.app = gplab.app.test_client()
def __init__(self, model_class): self.model_class = model_class self.key = model_class._key['all'] # We access directly _meta as .db is a property and should be # access from an instance, not a Class self._db = model_class._meta['db'] or redisco.get_client() self._filters = {} self._exclusions = {} self._zfilters = [] self._ordering = [] self._limit = None self._offset = None
def setup_database(): dbhost = environ.get("REDIS_PORT_6379_TCP_ADDR", "localhost") dbport = int(environ.get("REDIS_PORT_6379_TCP_PORT", "6379")) print("Waiting for Redis Service on {0:s}:{1:d} ...".format(dbhost, dbport)) waitfor(dbhost, dbport) print("Connecting to Redis on {0:s}:{1:d} ...".format(dbhost, dbport)) connection_setup(host=dbhost, port=dbport) print("Success!") db = get_client() return db
def setup_database(args, logger): dbhost = args.dbhost dbport = args.dbport logger.debug("Waiting for Redis Service on {0:s}:{1:d} ...".format( dbhost, dbport)) waitfor(dbhost, dbport) logger.debug("Connecting to Redis on {0:s}:{1:d} ...".format( dbhost, dbport)) connection_setup(host=dbhost, port=dbport) logger.debug("Success!") db = get_client() return db
def setup_database(args, logger): dbhost = args.dbhost dbport = args.dbport logger.debug( "Waiting for Redis Service on {0:s}:{1:d} ...".format(dbhost, dbport) ) waitfor(dbhost, dbport) logger.debug( "Connecting to Redis on {0:s}:{1:d} ...".format(dbhost, dbport) ) connection_setup(host=dbhost, port=dbport) logger.debug("Success!") db = get_client() return db
def setup_database(config, logger): dbhost = config["dbhost"] dbport = config["dbport"] logger.debug( "Waiting for Redis Service on {0:s}:{1:d} ...".format(dbhost, dbport) ) waitfor(dbhost, dbport) logger.debug( "Connecting to Redis on {0:s}:{1:d} ...".format(dbhost, dbport) ) connection_setup(host=dbhost, port=dbport) logger.debug("Success!") db = get_client() db.flushall() return db
def db(self): """Returns the Redis client used by the model.""" return redisco.get_client()
def exists(cls, id): """Checks if the model with id exists.""" _conn = cls._meta['db'] or redisco.get_client() return bool(_conn.exists(cls.instance_key(id)) or _conn.sismember(cls._all_key, str(id)))
def db(self): """Returns the Redis client used by the model.""" if self._meta['db']: return self._meta['db'] return redisco.get_client()
def display_results(results, name): print("%s: 5000 Loops, best of 3: %.02f sec" % (name, min(results))) def profile(): import cProfile import pstats stmt = """ for x in xrange(0, 5000): find_events() """ cProfile.run(stmt, "b33f.prof") p = pstats.Stats("b33f.prof") p.strip_dirs().sort_stats('cumulative').print_stats(20) db = get_client() db.flushdb() Event(name="Redis Meetup 1", location="London").save() t = timeit.Timer('create_events()', 'from __main__ import create_events') display_results(t.repeat(repeat=1, number=5000), 'create_events') t = timeit.Timer('find_events()', 'from __main__ import find_events') display_results(t.repeat(repeat=1, number=5000), 'find_events') t = timeit.Timer('load_events()', 'from __main__ import load_events') display_results(t.repeat(repeat=1, number=5000), 'load_events')
def db(cls): """Returns the Redis client used by the model.""" return cls.get_conn() or redisco.get_client()
def db(self): """Returns the Redis client used by the model.""" return redisco.get_client( ) if not self._meta['db'] else self._meta['db']
def setUp(self): self.client = redisco.get_client() self.client.flushdb()
def get_slug_id(): k = Key('slug') db = get_client() return db.incr(k['id'])
def db(self): """Returns the Redis client used by the model.""" return redisco.get_client() if not self._meta['db'] else self._meta['db']
def exists(cls, id): """Checks if the model with id exists.""" return bool((cls._meta['db'] or redisco.get_client()).exists(cls._key[str(id)]) or (cls._meta['db'] or redisco.get_client()).sismember(cls._key['all'], str(id)))
def exists(cls, id): """Checks if the model with id exists.""" return bool( (cls._meta['db'] or redisco.get_client()).exists(cls._key[str(id)]) or (cls._meta['db'] or redisco.get_client()).sismember( cls._key['all'], str(id)))
# coding: utf8 import logging from abc import ABCMeta, abstractmethod import redisco logger = logging.getLogger(__name__) rdb = redisco.get_client() class MarketDataApi(object): __metaclass__ = ABCMeta def __init__(self, quote_service, instruments, interval): self.quote_service = quote_service self.instruments = set(instruments) self.quote_service.interval = interval self.quote_service.mdapis.append(self) def start(self): self.subscribe(self.instruments) def process_tick(self, tick): # logger.debug(str(tick)) secid = tick.securityID rdb.hset('current_price', secid, tick.price) if hasattr(tick, 'b_price'): rdb.hset('current_b_price', secid, tick.b_price) if hasattr(tick, 's_price'): rdb.hset('current_s_price', secid, tick.s_price) rdb.publish('checkstop', secid)
def before_request(): g.redisco_client = redisco.get_client() #flask.g.app = app g.logger = app.logger