Commit 1a44b90f authored by Vincent Michel's avatar Vincent Michel Committed by Sebastien Petitdemange

Python 3 migration - Rename get_cache to get_redis_connection

parent 72c35c3c
......@@ -91,7 +91,7 @@ class Bus(AdvancedInstantiationInterface):
def __new__(cls, redis=None):
if redis is None:
redis = client.get_cache()
redis = client.get_redis_connection()
if redis not in cls._CACHE:
cls._CACHE[redis] = cls.instanciate(redis)
return cls._CACHE[redis]
......
......@@ -98,7 +98,7 @@ def get_cache_address(connection=None):
@check_connection
def get_cache(db=0, connection=None):
def get_redis_connection(db=0, connection=None):
return connection.get_redis_connection(db=db)
......
......@@ -67,8 +67,8 @@ def pickle_loads(var):
return InvalidValue()
def get_cache():
return client.get_cache(db=0)
def get_redis_connection():
return client.get_redis_connection(db=0)
def ttl_func(cnx, name, value=-1):
......@@ -154,7 +154,7 @@ def write_decorator(func):
def scan(match="*", count=1000, connection=None):
if connection is None:
connection = get_cache()
connection = get_redis_connection()
cursor = 0
while 1:
cursor, values = connection.scan(cursor=cursor, match=match, count=count)
......@@ -174,7 +174,7 @@ class SimpleSetting(object):
default_value=None,
):
if connection is None:
connection = get_cache()
connection = get_redis_connection()
self._cnx = weakref.ref(connection)
self._name = name
self._read_type_conversion = read_type_conversion
......@@ -264,7 +264,7 @@ class SimpleSettingProp(object):
use_object_name=True,
):
self._name = name
self._cnx = connection or get_cache()
self._cnx = connection or get_redis_connection()
self._read_type_conversion = read_type_conversion
self._write_type_conversion = write_type_conversion
self._default_value = default_value
......@@ -313,7 +313,7 @@ class QueueSetting(object):
write_type_conversion=str,
):
if connection is None:
connection = get_cache()
connection = get_redis_connection()
self._cnx = weakref.ref(connection)
self._name = name
self._read_type_conversion = read_type_conversion
......@@ -461,7 +461,7 @@ class QueueSettingProp(object):
use_object_name=True,
):
self._name = name
self._cnx = connection or get_cache()
self._cnx = connection or get_redis_connection()
self._read_type_conversion = read_type_conversion
self._write_type_conversion = write_type_conversion
self._use_object_name = use_object_name
......@@ -505,7 +505,7 @@ class HashSetting(object):
default_values={},
):
if connection is None:
connection = get_cache()
connection = get_redis_connection()
self._cnx = weakref.ref(connection)
self._name = name
self._read_type_conversion = read_type_conversion
......@@ -669,7 +669,7 @@ class HashSettingProp(object):
use_object_name=True,
):
self._name = name
self._cnx = connection or get_cache()
self._cnx = connection or get_redis_connection()
self._read_type_conversion = read_type_conversion
self._write_type_conversion = write_type_conversion
self._default_values = default_values
......
......@@ -102,7 +102,7 @@ def get_node(db_name, connection=None):
def get_nodes(*db_names, **keys):
connection = keys.get("connection")
if connection is None:
connection = client.get_cache(db=1)
connection = client.get_redis_connection(db=1)
pipeline = connection.pipeline()
for db_name in db_names:
data = Struct(db_name, connection=pipeline)
......@@ -120,13 +120,13 @@ def get_nodes(*db_names, **keys):
def _create_node(name, node_type=None, parent=None, connection=None, **keys):
if connection is None:
connection = client.get_cache(db=1)
connection = client.get_redis_connection(db=1)
return _get_node_object(node_type, name, parent, connection, create=True, **keys)
def _get_or_create_node(name, node_type=None, parent=None, connection=None, **keys):
if connection is None:
connection = client.get_cache(db=1)
connection = client.get_redis_connection(db=1)
db_name = DataNode.exists(name, parent, connection)
if db_name:
return get_node(db_name, connection=connection)
......@@ -368,7 +368,7 @@ class DataNode(object):
@staticmethod
def exists(name, parent=None, connection=None):
if connection is None:
connection = client.get_cache(db=1)
connection = client.get_redis_connection(db=1)
db_name = "%s:%s" % (parent.db_name, name) if parent else name
return db_name if connection.exists(db_name) else None
......@@ -377,7 +377,7 @@ class DataNode(object):
):
info_dict = keys.pop("info", {})
if connection is None:
connection = client.get_cache(db=1)
connection = client.get_redis_connection(db=1)
db_name = "%s:%s" % (parent.db_name, name) if parent else name
self._data = Struct(db_name, connection=connection)
info_hash_name = "%s_info" % db_name
......@@ -444,7 +444,7 @@ class DataNode(object):
def set_ttl(self):
db_names = set(self._get_db_names())
redis_conn = client.get_cache(db=1)
redis_conn = client.get_redis_connection(db=1)
pipeline = redis_conn.pipeline()
for name in db_names:
pipeline.expire(name, DataNode.default_time_to_live)
......
......@@ -31,7 +31,7 @@ from bliss.flint.executor import concurrent_to_gevent
from bliss.flint.executor import qt_safe
from bliss.flint.executor import QtSignalQueue
from bliss.config.conductor.client import get_default_connection
from bliss.config.conductor.client import get_cache as get_redis_connection
from bliss.config.conductor.client import get_redis_connection
try:
from PyQt4.QtCore import pyqtRemoveInputHook
......
......@@ -148,7 +148,7 @@ def test_with_another_process(beacon, beacon_host_port):
del c
# Check channel is really not there anymore
redis = channels.client.get_cache()
redis = channels.client.get_redis_connection()
bus = channels.Bus._CACHE[redis]
assert "test_chan" not in bus._channels
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment