Example #1
0
 /**
  * @param $name
  */
 public function del($name)
 {
     if (isset($this->buffer[$name])) {
         unset($this->buffer[$name]);
     }
     $this->client->del($name);
 }
Example #2
0
 public function flushIndex()
 {
     if ($this->indexing) {
         $this->store->del("{$this->prefix}::index");
     }
     return parent::flushIndex();
 }
Example #3
0
 /**
  * Remove values from cache
  *
  * @param  array $keys list of keys to delete
  *
  * @return boolean true on success, false on failure
  */
 protected function delete(array $keys)
 {
     foreach ($keys as $k) {
         $k = sha1($k);
         $this->redis->del($k);
     }
     return true;
 }
Example #4
0
 /**
  * @param array $keys
  * @return bool
  */
 public function deleteItems(array $keys)
 {
     $return = $this->client->del($keys);
     if ($return > 0) {
         return true;
     }
     return false;
 }
Example #5
0
 /**
  * @param $key
  * @throws UnavailableException
  */
 public function remove($key)
 {
     try {
         $this->client->del([$key]);
     } catch (ServerException $ex) {
         throw new UnavailableException($ex->getMessage());
     }
 }
Example #6
0
 /**
  * @param $queueName
  * @return QueueItemInterface
  */
 public function popItem($queueName)
 {
     $this->getKeys($queueName, true);
     $key = array_pop($this->keys);
     $itemRaw = $this->redis->get($key);
     $item = unserialize($itemRaw);
     $this->redis->del($key);
     return $item;
 }
 /**
  * {@inheritDoc}
  */
 public function count(array $sources)
 {
     call_user_func_array([$this->redis, 'zunionstore'], array_merge([$key = sha1(microtime()), count($sources)], array_map(function ($source) {
         return "aggregator:sources:{$source}";
     }, $sources)));
     $count = $this->redis->zcard($key);
     $this->redis->del($key);
     return $count;
 }
Example #8
0
 /**
  * {@inheritdoc}
  */
 protected function delete(array $keys)
 {
     try {
         $this->client->del($keys);
     } catch (\Predis\Response\ServerException $e) {
         return false;
     }
     return true;
 }
 /**
  * Checks if the activation key is present in the redis database.
  *
  * @param string $activationKey
  *
  * @return bool
  */
 private function lookupKeyInRedisDatabase($activationKey)
 {
     $persistentKey = $this->generateRedisKeyByApprovalKey($activationKey);
     $exists = $this->redis->exists($persistentKey);
     // the key is not needed anymore because the approval validation will be triggered once only.
     if ($exists) {
         $this->redis->del($persistentKey);
     }
     return $exists;
 }
Example #10
0
 /**
  * @inheritdoc
  */
 public function recheck($event)
 {
     $value = $this->client->get($event);
     if (!$value) {
         return;
     }
     foreach ($this->listeners[$event] ?? [] as $listener) {
         $listener($value);
     }
     $this->client->del([$event]);
 }
 public function logout()
 {
     $userId = $this->session->get('userId');
     $newAuthSecret = $this->getRand();
     $oldAuthSecret = $this->redisClient->get("uid:{$userId}:auth");
     $this->redisClient->set("uid:{$userId}:auth", $newAuthSecret);
     $this->redisClient->set("auth:{$newAuthSecret}", $userId);
     $this->redisClient->del("auth:{$oldAuthSecret}");
     $this->session->set('userId', null);
     $this->session->set('username', null);
 }
Example #12
0
 /**
  * @param $key
  *
  * @return int
  */
 public function removeWithName($key)
 {
     $result = 0;
     // se key ha l'asterisco, cancella tutte le chiavi che iniziano per il prefisso in $key
     if (strpos($key, '*') !== false) {
         foreach ($this->redis->keys($key) as $k) {
             $result += $this->redis->del($k);
         }
     } else {
         $result += $this->redis->del($key);
     }
     return $result;
 }
 public function clearQueue($stub)
 {
     for ($x = 0; $x < 10; $x++) {
         $iterator = new Iterator\Keyspace($this->redisClient, $stub . "*", 200);
         $keysToDelete = [];
         foreach ($iterator as $key) {
             $keysToDelete[] = $key;
         }
         if (count($keysToDelete)) {
             $this->redisClient->del($keysToDelete);
         }
     }
 }
 /**
  *
  */
 private function revokeAccess()
 {
     $accessToken = $this->redis->get(self::REDIS_ACCESS_TOKEN);
     $this->redis->del(self::REDIS_ACCESS_TOKEN);
     $this->redis->del(self::REDIS_REFRESH_TOKEN);
     $this->googleClient->revokeToken($accessToken);
 }
 /**
  * @param string $providerPrefix
  *
  * @return bool
  */
 public function invalidate($providerPrefix)
 {
     $keys = $this->client->keys($this->prefix . strtolower($providerPrefix) . '_*');
     foreach ($keys as $key) {
         $this->client->del($key);
     }
     return true;
 }
Example #16
0
 /**
  * {@inheritdoc}
  */
 public function reconnect()
 {
     $this->logger->debug('Client ' . $this . ': reconnect process has been requested, kill the old process and create a new one');
     Process::killProcess($this->pidPath, true, $this->logger, $this);
     $this->redis->del($this->getKey('invokeId'));
     $this->connect();
     $this->authenticate();
 }
Example #17
0
 /**
  * @param int|string $sessionId
  *
  * @return bool
  */
 public function destroy($sessionId)
 {
     $key = $this->keyPrefix . $sessionId;
     $startTime = microtime(true);
     $this->connection->del($key);
     $this->newRelicApi->addCustomMetric(self::METRIC_SESSION_DELETE_TIME, microtime(true) - $startTime);
     return true;
 }
 private function flushRedisCache($pattern)
 {
     $config = config('database.redis.' . config('cache.stores.redis.connection'));
     $client = new Redis(['scheme' => 'tcp', 'host' => $config['host'], 'port' => $config['port'], 'parameters' => ['password' => $config['password'], 'database' => $config['database']]]);
     $keys = $client->keys('collejo:criteria:' . str_replace('\\', '\\\\', $pattern) . ':*');
     foreach ($keys as $key) {
         $client->del($key);
     }
 }
Example #19
0
 /**
  * Delete all keys from redis
  */
 protected function clearCache()
 {
     $this->logger->info('Clearing cache...');
     $keys = $this->redis->keys('elogank.api.*');
     if (null != $keys) {
         foreach ($keys as $key) {
             $this->redis->del($key);
         }
     }
 }
Example #20
0
 /**
  * @param Application $app
  *
  * @return string token
  */
 public function handleAuth(Application $app)
 {
     $code = $app->request()->get('code');
     $state = $app->request()->get('state');
     $key = sprintf('google.oauth2state.%s', session_id());
     $sessionState = $this->redisClient->get($key);
     if (is_null($code)) {
         // If we don't have an authorization code then get one
         $url = $this->oauth2Provider->getAuthorizationUrl();
         $this->redisClient->setex($key, 300, $this->oauth2Provider->state);
         $app->redirect($url);
     } elseif (empty($state) || isset($sessionState) && $state !== $sessionState) {
         // Check given state against previously stored one to mitigate CSRF attack
         $this->redisClient->del($key);
         throw new \RuntimeException('Invalid state');
     }
     // clean session
     $this->redisClient->del($key);
     // Try to get an access token (using the authorization code grant)
     return $this->oauth2Provider->getAccessToken('authorization_code', ['code' => $code])->accessToken;
 }
 /**
  * @param Session $session
  */
 public function set(Session $session)
 {
     $sid = $session->getSessionId();
     $redisId = $this->buildKey($sid);
     if ($session->shouldKill()) {
         $this->redis->del($redisId);
     } else {
         $this->redis->transaction(function (MultiExec $tx) use($session, $redisId) {
             foreach ($session->getDeletedKeys() as $key) {
                 $tx->hdel($redisId, $key);
             }
             $changes = $session->getChanges();
             if (count($changes) > 0) {
                 $tx->hmset($redisId, $session->getChanges());
             }
             // session regeneration is not supported
             $tx->expire($redisId, $this->getExpires());
         });
         $this->oracleKeepAlive($sid);
     }
 }
 /**
  * Immediately delete association from Redis.
  */
 function removeAssociation($server_url, $handle)
 {
     // create Redis keys
     $serverKey = $this->associationServerKey($server_url);
     $associationKey = $this->associationKey($server_url, $handle);
     // Removing the association from the server's association list
     $removed = $this->redis->lrem($serverKey, 0, $associationKey);
     if ($removed < 1) {
         return false;
     }
     // Delete the association itself
     return $this->redis->del($associationKey);
 }
Example #23
0
 /**
  * @param Application $app
  *
  * @return string token
  */
 public function handleAuth(Application $app)
 {
     $oauthToken = $app->request()->get('oauth_token');
     $oauthVerifier = $app->request()->get('oauth_verifier');
     $key = sprintf('bitbucket.oauthCredential.%s', session_id());
     $temporaryCredential = $this->redisClient->get($key);
     if (!empty($temporaryCredential)) {
         $temporaryCredential = unserialize($temporaryCredential);
     }
     if (empty($temporaryCredential)) {
         // If we don't have an authorization code then get one
         $temporaryCredential = $this->oauthProvider->getTemporaryCredentials();
         $this->redisClient->setex($key, 300, serialize($temporaryCredential));
         $app->redirect($this->oauthProvider->getAuthorizationUrl($temporaryCredential));
     } elseif (empty($oauthVerifier) || empty($oauthToken)) {
         // Check callback
         $this->redisClient->del($key);
         throw new \RuntimeException('Invalid state');
     }
     // clean session
     $this->redisClient->del($key);
     $tokenCredentials = $this->oauthProvider->getTokenCredentials($temporaryCredential, $oauthToken, $oauthVerifier);
     return $tokenCredentials->getIdentifier() . '@' . $tokenCredentials->getSecret();
 }
Example #24
0
 /**
  * {@inheritdoc}
  */
 public function clear($key = null)
 {
     if (is_null($key)) {
         $this->redis->flushdb();
         return true;
     }
     $keyString = $this->makeKeyString($key, true);
     $keyReal = $this->makeKeyString($key);
     $this->redis->incr($keyString);
     // increment index for children items
     $this->redis->del($keyReal);
     // remove direct item.
     $this->keyCache = array();
     return true;
 }
 /**
  * @param Session $session
  */
 public function set(Session $session)
 {
     $redisId = $this->buildKey($session->getSessionId());
     if ($session->shouldKill()) {
         $this->redis->del($redisId);
     } else {
         $this->redis->transaction(function (MultiExec $tx) use($session, $redisId) {
             foreach ($session->getDeletedKeys() as $key) {
                 $tx->hdel($redisId, $key);
             }
             $changes = $session->getChanges();
             if (count($changes) > 0) {
                 $tx->hmset($redisId, $session->getChanges());
             }
             if ($session->shouldRegenerate()) {
                 $session->setSid(UUID::v4());
                 $newRedisId = $this->buildKey($session->getSessionId());
                 $tx->rename($redisId, $newRedisId);
                 $redisId = $newRedisId;
             }
             $tx->expire($redisId, $this->getExpires());
         });
     }
 }
Example #26
0
 /**
  * {@inheritdoc}
  */
 public function delete($id)
 {
     return $this->client->del($this->prefix . $id) > 0;
 }
Example #27
0
 /**
  * @param Password $password
  */
 public function delete(Password $password)
 {
     $this->client->del($password->getId());
 }
Example #28
0
 public function expire($key)
 {
     $this->client->del($this->prefixTimestamp($key));
     return (int) $this->client->del($this->prefixKey($key)) === 1;
 }
Example #29
0
 /**
  * Removes a key-value pair.
  *
  * @param string $key Cache key.
  *
  * @return boolean
  */
 public function remove($key)
 {
     return $this->redisClient->del($key);
 }
Example #30
0
 public function deleteQueue($queueId = null)
 {
     $queueId = $this->normaliseQueueId($queueId);
     $this->predis->del($queueId);
 }