def update_locks_cache(chat_id): key = 'locks_cache_{}'.format(chat_id) redis.delete(key) data = mongodb.locks.find_one({'chat_id': chat_id}) if not data: return False for lock in data: if lock == 'chat_id' or lock == '_id': continue if data[lock] is True: redis.lpush(key, lock) redis.expire(key, 3600) return True
def update_handlers_cache(chat_id): filters = mongodb.filters.find({'chat_id': chat_id}) redis.delete('filters_cache_{}'.format(chat_id)) for filter in filters: redis.lpush('filters_cache_{}'.format(chat_id), filter['handler'])