Exemplo n.º 1
0
 /**
  * @param $name
  */
 public function del($name)
 {
     if (isset($this->buffer[$name])) {
         unset($this->buffer[$name]);
     }
     $this->client->del($name);
 }
Exemplo n.º 2
0
 public function flushIndex()
 {
     if ($this->indexing) {
         $this->store->del("{$this->prefix}::index");
     }
     return parent::flushIndex();
 }
Exemplo n.º 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;
 }
Exemplo n.º 4
0
 /**
  * @param array $keys
  * @return bool
  */
 public function deleteItems(array $keys)
 {
     $return = $this->client->del($keys);
     if ($return > 0) {
         return true;
     }
     return false;
 }
Exemplo n.º 5
0
 /**
  * @param $key
  * @throws UnavailableException
  */
 public function remove($key)
 {
     try {
         $this->client->del([$key]);
     } catch (ServerException $ex) {
         throw new UnavailableException($ex->getMessage());
     }
 }
Exemplo n.º 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;
 }
Exemplo n.º 7
0
 /**
  * {@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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 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);
 }
Exemplo n.º 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;
 }
Exemplo n.º 13
0
 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);
         }
     }
 }
Exemplo n.º 14
0
 /**
  *
  */
 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);
 }
Exemplo n.º 15
0
 /**
  * @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;
 }
Exemplo n.º 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();
 }
Exemplo n.º 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;
 }
Exemplo n.º 18
0
 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);
     }
 }
Exemplo n.º 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);
         }
     }
 }
Exemplo n.º 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);
     }
 }
Exemplo n.º 22
0
 /**
  * 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);
 }
Exemplo n.º 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();
 }
Exemplo n.º 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;
 }
Exemplo n.º 25
0
 /**
  * @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());
         });
     }
 }
Exemplo n.º 26
0
 /**
  * {@inheritdoc}
  */
 public function delete($id)
 {
     return $this->client->del($this->prefix . $id) > 0;
 }
Exemplo n.º 27
0
 /**
  * @param Password $password
  */
 public function delete(Password $password)
 {
     $this->client->del($password->getId());
 }
Exemplo n.º 28
0
 public function expire($key)
 {
     $this->client->del($this->prefixTimestamp($key));
     return (int) $this->client->del($this->prefixKey($key)) === 1;
 }
Exemplo n.º 29
0
 /**
  * Removes a key-value pair.
  *
  * @param string $key Cache key.
  *
  * @return boolean
  */
 public function remove($key)
 {
     return $this->redisClient->del($key);
 }
Exemplo n.º 30
0
 public function deleteQueue($queueId = null)
 {
     $queueId = $this->normaliseQueueId($queueId);
     $this->predis->del($queueId);
 }