Exemple #1
0
'''
Cache sync service
'''

__author__ = 'alex'
__version__  = '0.0.1'

import redis
import psycopg2
import psycopg2.extensions

from sync import loop
from updaters.redis import updater

channel_filters = {
    'guide': ['guide/%s',
              'guide/%s/*'],
    'page': ['guide/*/page/%s',
             ]
}

REDIS_PREFIX = "flask_cache_view//v1/"

if __name__ == '__main__':
    print "Cache sync v %s" % __version__
    r = redis.StrictRedis(db=2)
    connection = psycopg2.connect(database="webguide", user="******", password="******")
    connection.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
    loop.run(connection, updater(r, REDIS_PREFIX), channel_filters)
Exemple #2
0
'''

__author__ = 'alex'
__version__  = '0.0.1'


import psycopg2
import psycopg2.extensions
from elasticsearch import Elasticsearch

import model
import conf

from sync import loop
from updaters.elasticsearch import updater

channel_params = {
    'guide': (model.Guide,),
    'page': (model.Page,),
}


if __name__ == '__main__':
    print "Search sync v %s" % __version__

    connection = psycopg2.connect(database="webguide", user="******", password="******")
    connection.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)
    es = Elasticsearch([{'host': 'localhost', 'port': 9200}])
    loop.run(connection, updater(es, conf.ES_INDEX), channel_params)