# Path: netl2api/lib/config.py
# def get_netl2server_cfg():
#     return get_cfg("netl2server", check_permission=None)


import redis
from netl2api.lib.config import get_netl2server_cfg
#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
#
# @author: Eduardo S. Scarpellini
# @author: Luiz Ozaki


__copyright__ = "Copyright 2012, Locaweb IDC"




__all__ = ["RedisClient"]


cfg = get_netl2server_cfg()


class RedisClient(object):
    def __init__(self, db=7, timeout=3):
        self.host = cfg.get("redis", "host")
        self.port = cfg.getint("redis", "port")
        self.timeout  = timeout
        self.redis_db = db
        self._redis   = redis.Redis(host=self.host, port=self.port, db=self.redis_db,
                                      socket_timeout=self.timeout)

    def get_connection(self):
        if self._redis is None or not self._redis.ping():

# Path: netl2api/lib/config.py
# def get_netl2server_cfg():
#     return get_cfg("netl2server", check_permission=None)


# Path: netl2api/server/utils.py
import redis
from netl2api.lib.config import get_netl2server_cfg

#    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#    See the License for the specific language governing permissions and
#    limitations under the License.
#
# @author: Eduardo S. Scarpellini
# @author: Luiz Ozaki


__copyright__ = "Copyright 2012, Locaweb IDC"




__all__ = ["RedisClient"]


cfg = get_netl2server_cfg()


class RedisClient(object):
    def __init__(self, db=7, timeout=3):
        self.host = cfg.get("redis", "host")
        self.port = cfg.getint("redis", "port")
        self.timeout  = timeout
        self.redis_db = db
        self._redis   = redis.Redis(host=self.host, port=self.port, db=self.redis_db,
                                      socket_timeout=self.timeout)

    def get_connection(self):
        if self._redis is None or not self._redis.ping():

            self._redis = redis.Redis(host=self.host, port=self.port, db=self.redis_db,