Setups redis to flush db after suite and before each example with
 `flush_redis: :true`. `Rails.redis` client is used by default.
 Can be tuned with `config.redis`.
342102
def redis
      ::RSpec.configure do |config|
        config.add_setting :redis
        config.redis = Rails.redis if defined?(Rails.redis)
        config.add_setting :flush_redis_proc
        config.flush_redis_proc = ->(*) { Array.wrap(config.redis).each(&:flushdb) }
        config.before(flush_redis: true) { instance_exec(&config.flush_redis_proc) }
        config.after(:suite) { instance_exec(&config.flush_redis_proc) }
      end
    end
233800
def clone(client):
        ''''''
        kwargs = client.redis.connection_pool.connection_kwargs
        kwargs['parser_class'] = redis.connection.PythonParser
        pool = redis.connection.ConnectionPool(**kwargs)
        return redis.Redis(connection_pool=pool)
900031
def check_redis():
        
        from pyoko.db.connection import cache
        from redis.exceptions import ConnectionError

        try:
            cache.ping()
            print(CheckList.OKGREEN + "{0}Redis is working{1}" + CheckList.ENDC)
        except ConnectionError as e:
            print(__(u"{0}Redis is not working{1} ").format(CheckList.FAIL,
                                                            CheckList.ENDC), e.message)
667839
def refresh_db(force=False, **kwargs):
    '''
    
    '''
    # Remove rtag file to keep multiple refreshes from happening in pkg states
    salt.utils.pkg.clear_rtag(__opts__)
    pkgin = _check_pkgin()

    if pkgin:
        cmd = [pkgin, 'up']
        if force:
            cmd.insert(1, '-f')
        call = __salt__['cmd.run_all'](cmd, output_loglevel='trace')

        if call['retcode'] != 0:
            comment = ''
            if 'stderr' in call:
                comment += call['stderr']

            raise CommandExecutionError(comment)

    return True
537420
function makePool(options, database) {
    return Pool({
        name: options.name + ':' + database,

        create: function(callback) {

            var callbackCalled = false;

            var client = redis.createClient(options.port, options.host, {
                no_ready_check: options.noReadyCheck
            });

            client.on('error', function (err) {
                log(options, {db: database, action: 'error', err: err.message});
                if (!callbackCalled) {
                    callbackCalled = true;
                    callback(err, client);
                }
                client.end(FLUSH_CONNECTION);
            });

            client.on('ready', function () {
                client.select(database, function(err/*, res*/) {
                    if (!callbackCalled) {
                        callbackCalled = true;
                        callback(err, client);
                    }
                });
            });
        },

        destroy: function(client) {
            client.quit();
            client.end(FLUSH_CONNECTION);
        },

        validate: function(client) {
            return client && client.connected;
        },

        max: options.max,
        idleTimeoutMillis: options.idleTimeoutMillis,
        reapIntervalMillis: options.reapIntervalMillis,
        returnToHead: options.returnToHead,
        log: options.log
    });
}
489313
def redis
      if defined?($redis) && $redis
        Redis.new($redis.client.options)
      elsif defined?(REDIS) && REDIS
        Redis.new(REDIS.client.options)
      else
        Redis.new
      end
    end
1008067
def fake2db_redis_initiator(self, host, port, number_of_rows, name=None, custom=None):
        '''
        '''

        client, pipe = self.database_caller_creator(host, port, name)

        if custom:
            self.custom_db_creator(number_of_rows, pipe, custom)
            client.save()
            sys.exit(0)

        self.data_filler_simple_registration(number_of_rows, pipe)
        self.data_filler_detailed_registration(number_of_rows, pipe)
        self.data_filler_company(number_of_rows, pipe)
        self.data_filler_user_agent(number_of_rows, pipe)
        self.data_filler_customer(number_of_rows, pipe)

        client.save()
529754
def flush(self, timeout=None, callback=None):
        """"""
        client, scope = self._stack[-1]
        if client is not None:
            return client.flush(timeout=timeout, callback=callback)
564029
def after_call
      env_session = @request.env['redd.session']
      if env_session && env_session.client.access
        # Make sure to flush any changes made to the Session client to the browser.
        @request.session[:redd_session] = env_session.client.access.to_h
      else
        # Clear the session if the app explicitly set 'redd.session' to nil.
        @request.session.delete(:redd_session)
      end
    end
57193
public function clear_redis_cache()
    {

        $redis_host = config('database.redis.default.host');
        $redis_port = config('database.redis.default.port');

        $this->info('Clearing the Redis Cache at: ' . $redis_host . ':' . $redis_port);

        try {

            $redis = new Client([
                'host' => $redis_host,
                'port' => $redis_port,
            ]);
            $redis->flushall();
            $redis->disconnect();

        } catch (Exception $e) {

            $this->error('Failed to clear the Redis Cache. Error: ' . $e->getMessage());

        }

    }
496483
def flush(bank, key=None):
    '''
    
    '''
    _init_client()
    query = "DELETE FROM {0} WHERE bank='{1}'".format(_table_name, bank)
    if key is not None:
        query += " AND etcd_key='{0}'".format(key)

    cur, _ = run_query(client, query)
    cur.close()
265486
public function setRedis(?RedisClient $redis = null)
    {
        if (! $redis) {
            $server = Arr::get($this->config, 'server', []);
            $options = Arr::get($this->config, 'options', []);

            // forbid setting prefix from options
            if (Arr::has($options, 'prefix')) {
                $options = Arr::except($options, 'prefix');
            }

            $redis = new RedisClient($server, $options);
        }

        $this->redis = $redis;
    }
536998
public function onReady()
    {
        $this->redis = \PHPDaemon\Clients\Redis\Pool::getInstance();

        $this->redis->hmset('myset', 'field1', 'value1', 'field2', 'value2', 'field3', 'value3', 'field4', 'value4',
            'field5', 'value5', function ($redis) {
                $this->redis->hgetall('myset', function ($redis) {
                    D('TEST 1: HGETALL');
                    foreach ($redis as $key => $value) {
                        D($key . ' - ' . $value);
                    }
                    D($redis->assoc);
                });

                $this->redis->hmget('myset', 'field2', 'field4', function ($redis) {
                    D('TEST 2: HMGET');
                    foreach ($redis as $key => $value) {
                        D($key . ' - ' . $value);
                    }
                    D($redis->assoc);
                });
            });

        $this->redis->zadd('myzset', 100, 'one', 150, 'two', 325, 'three', function ($redis) {
            $this->redis->zrange('myzset', 0, -1, function ($redis) {
                D('TEST 3: ZRANGE');
                foreach ($redis as $key => $value) {
                    D($key . ' - ' . $value);
                }
                D($redis->assoc);
            });

            $this->redis->zrange('myzset', 0, -1, 'WITHSCORES', function ($redis) {
                D('TEST 4: ZRANGE WITHSCORES');
                foreach ($redis as $key => $value) {
                    D($key . ' - ' . $value);
                }
                D($redis->assoc);
            });
        });

        $this->redis->subscribe('mysub', function ($redis) {
            D('TEST 5: SUB & PUB');
            foreach ($redis as $key => $value) {
                D($key . ' - ' . $value);
            }
            D($redis->channel, $redis->msg, $redis->assoc);
        });

        $this->redis->publish('mysub', 'Test message!');
    }
101618
def start(redis)
      logger.debug { "Scat is starting the Redis cache server..." }
      unless system(REDIS_SERVER, REDIS_CONF) then
        raise ScatError.new("Scat cannot start the Redis cache server.")
      end
      # Ping the server until loaded. 
      3.times do |n|
        begin
          redis.ping
          logger.debug { "Scat started the Redis cache server." }
          return redis
        rescue
          n < 2 ? sleep(0.5) : raise
        end
      end
    end
616525
def inject(clients={})
      @_injected_clients = true
      clients.each_pair do |name, client|
        _close_if_present(@_connections[name])
        @_connections[name] = Redis::Namespace.new(DEFAULT_NAMESPACE, redis: client)
      end
    end
1027054
async def init():
    """"""
    global redis_conn  # pylint: disable=global-statement,invalid-name
    conn = await aioredis.create_connection(
        'redis://{}:{}'.format(
            SETTINGS.get('FLOW_EXECUTOR', {}).get('REDIS_CONNECTION', {}).get('host', 'localhost'),
            SETTINGS.get('FLOW_EXECUTOR', {}).get('REDIS_CONNECTION', {}).get('port', 56379)
        ),
        db=int(SETTINGS.get('FLOW_EXECUTOR', {}).get('REDIS_CONNECTION', {}).get('db', 1))
    )
    redis_conn = aioredis.Redis(conn)
553527
def _pre_tasks(self):
        
        if self.flushdb:
            management.call_command('flush', verbosity=0, interactive=False)
            logger.info('Flushed database')