Delete expired resources.

@return array
163573
public function handleExpiration() : array
    {
        $deleted   = [];
        $cacheKeys = $this->cache->keys();

        foreach ($cacheKeys as $key) {
            $fileMeta = $this->cache->get($key, true);

            if ( ! $this->isExpired($fileMeta)) {
                continue;
            }

            if ( ! $this->cache->delete($key)) {
                continue;
            }

            if (is_writable($fileMeta['file_path'])) {
                unlink($fileMeta['file_path']);
            }

            $deleted[] = $fileMeta;
        }

        return $deleted;
    }
306272
public function deleteOutdated(): bool
    {
        $keys = $this->db->keys('*');
        foreach ($keys as $key) {
            try {
                $packet = $this->getPacket($key);
                if ($packet->outdated()) {
                    $this->delete($key);
                }
            } catch (BadPacketException $e) {
                $this->delete($key);
            }
        }
        return true;
    }
1340423
public function deleteFromIndex()
    {
        $all = $this->all();

        $params = array();

        foreach ($all as $item) {
            $params['body'][] = array(
                'delete' => array(
                    '_id' => $item->getKey(),
                    '_type' => $item->getTypeName(),
                    '_index' => $item->getIndexName(),
                ),
            );
        }

        return $this->getElasticSearchClient()->bulk($params);
    }
816507
private function pruneTokens()
    {
        $now = new \DateTime('now');
        // Delete access tokens that have no refresh token associated
        $qb = $this->entityManager->createQueryBuilder();
        $items = $qb->select('token')
            ->from(AccessToken::class, 'token')
            ->where($qb->expr()->lt('token.expiryDateTime', ':now'))
            ->getQuery()->execute([':now' => $now]);

        $this->pruneResults($items);

        // Delete all expired access tokens that have expired refresh tokens
        $qb = $this->entityManager->createQueryBuilder();
        $items = $qb->select('token')
            ->from(AccessToken::class, 'token')
            ->where($qb->expr()->lt('token.expiryDateTime', ':now'))
            ->getQuery()->execute([':now' => $now]);

        $this->pruneResults($items);

        // Delete all expired auth codes
        $qb = $this->entityManager->createQueryBuilder();
        $qb->delete(AuthCode::class, 'token')
            ->where($qb->expr()->lt('token.expiryDateTime', ':now'))
            ->getQuery()->execute([':now' => $now]);
    }
523370
public function expireAll()
    {
        if (!$this->enabled)
            return true;

        $this->Logger->debug('Expire all keys');

        $apcMethod = $this->apcFuncPrefix.'_clear_cache';
        $apcMethod();

        return $apcMethod('user');
    }
98885
def remove_expired_multipartobjects():
    """"""
    delta = current_app.config['FILES_REST_MULTIPART_EXPIRES']
    expired_dt = datetime.utcnow() - delta

    file_ids = []
    for mp in MultipartObject.query_expired(expired_dt):
        file_ids.append(str(mp.file_id))
        mp.delete()

    for fid in file_ids:
        remove_file_data.delay(fid)
1219242
protected function expireResponses()
    {
        $now = TimeSupport::now();
        $expiredReps = [];

        foreach ($this->handledReps as $pid=>$response)
        {
            if ($now >= $response->timeout)
            {
                $expiredReps[] = $pid;
            }
        }

        foreach ($expiredReps as $pid)
        {
            unset($this->handledReps[$pid]);
        }
    }
19071
public function removeIfExpired()
    {
        if ($this->getIsExpired() && !$this->getIsNewRecord()) {
            if (($this->expiredRemovingCallback instanceof Closure || is_array($this->expiredRemovingCallback)) && is_callable($this->expiredRemovingCallback)) {
                call_user_func($this->expiredRemovingCallback, $this);
            }
            $result = $this->removeSelf();
            $this->trigger(static::$eventExpiredRemoved, new ModelEvent(['data' => ['result' => $result]]));
            return true;
        }
        return false;
    }
175163
public function delete()
    {
        return
            is_null($this->resourceLink) ||
            $this->resourceLink->getConsumer()->getStorage()->User_delete($this);
    }
1326407
public function deleteExpired()
    {
        if ($this->isExpirationEnabled()) {
            $expiredAt = Carbon::now()->subSeconds($this->expires);

            $this->getTable()->where('created_at', '<', $expiredAt)->delete();
        }
    }
498175
public function findExpiredIdentifiers(): array
    {
        $queryBuilder = $this->createQuery();
        $rows = $queryBuilder->select('identifier')
            ->from($this->getTableName())
            ->where($queryBuilder->expr()->lt(
                'expires',
                $queryBuilder->createNamedParameter((new DateTimeService())->getCurrentTime(), \PDO::PARAM_INT)
            ))
            ->groupBy('identifier')
            ->execute()
            ->fetchAll();

        $cacheIdentifiers = [];
        foreach ($rows as $row) {
            $cacheIdentifiers[] = $row['identifier'];
        }

        return $cacheIdentifiers;
    }
308112
public function clear()
    {
        $this->logInfo('Clearing Session.');

        $metadata = $this->getMetadataBag();
        $lifetime = $metadata->getLifetime();
        $lastUsed = $metadata->getLastUsed();

        // If the existing session has expired on its own
        if ($lifetime && time() > $lastUsed + $lifetime) {
            $this->logInfo('Session expired.');
        }

        return $this->wrappedStorage->clear();
    }
195161
public function deleteAll()
    {
        $this->preDeleteAll();
        $result = $this->dataStore->deleteAll();

        return $this->postDeleteAll($result);
    }
238995
public function removeExpired(): int
    {
        $queryBuilder = $this->getEntityManager()->createQueryBuilder();
        $queryBuilder->delete(AdministratorToken::class, 'token')->where('token.expiry <= CURRENT_TIMESTAMP()');

        return (int)$queryBuilder->getQuery()->execute();
    }
1370560
protected function deleteExpiredRecords()
    {
        try {
            $limit = (int)($this->limitDuration);
        } catch (\Exception $ex) {
            Yii::error($ex->getMessage(), __METHOD__);
            return 0;
        }
        $count = 0;
        $host = $this->host;
        /* @var $host \rhosocial\user\User */
        foreach (static::find()
                ->createdBy($host)
                ->andWhere(['<=', $this->createdAtAttribute, $this->offsetDatetime($this->currentUtcDatetime(), -$limit)])
                ->all() as $login) {
            /* @var $login static */
            $result = $login->delete();
            $count += $result;
            if (YII_ENV_DEV) {
                Yii::info($host->getReadableGUID() . ": ($result) login record created at (" . $login->getCreatedAt() . ") was just deleted.", __METHOD__);
            }
        }
        return $count;
    }
547781
public function deleteExpired()
    {
        // General expirations. Maximum limiter is 1m.
        $oldest = new \DateTime('-1 month -1 day');
        $q      = $this->getEntityManager()->getConnection()->createQueryBuilder();
        $q->delete(MAUTIC_TABLE_PREFIX.$this->getTableName());
        $q->where(
            $q->expr()->lt('date_added', 'FROM_UNIXTIME(:oldest)')
        );
        $q->setParameter('oldest', (int) $oldest->getTimestamp());
        $q->execute();
    }
34354
public function deleteExpiredTokens()
    {
        $lifetime = config('autologin.lifetime');

        $expiry = Carbon::now()->subMinutes($lifetime);

        return $this->provider->deleteExpiredTokens($expiry);
    }