Removes any rules with an expiration date in the past.
426825
def ExpireRules(self):
    """"""
    rules = self.Get(self.Schema.RULES)
    new_rules = self.Schema.RULES()
    now = time.time() * 1e6
    expired_session_ids = set()

    for rule in rules:
      if rule.expires > now:
        new_rules.Append(rule)
      else:
        for action in rule.actions:
          if action.hunt_id:
            expired_session_ids.add(action.hunt_id)

    if expired_session_ids:
      with data_store.DB.GetMutationPool() as pool:
        # Notify the worker to mark this hunt as terminated.
        manager = queue_manager.QueueManager(token=self.token)
        manager.MultiNotifyQueue([
            rdf_flows.GrrNotification(session_id=session_id)
            for session_id in expired_session_ids
        ],
                                 mutation_pool=pool)

    if len(new_rules) < len(rules):
      self.Set(self.Schema.RULES, new_rules)
      self.Flush()
60870
def prune_database():
    
    now = datetime.now()
    expired = TokenBlacklist.query.filter(TokenBlacklist.expires < now).all()
    for token in expired:
        db.session.delete(token)
    db.session.commit()
1028846
private function cleanup()
    {
        if (isset($this->collection[$this->id_info])) {
            foreach ($this->collection[$this->id_info] as $key => $val) {
                $expire = $this->getSessionInfo($key, 'expire');
                if ($expire === true) {
                    $this->setSessionInfo($key, 'expire', -1);
                } elseif ($expire == -1) {
                    $this->delete($key);
                }
            }
        }
    }
503519
def _clean_key_expiration_option(self):
        """"""
        allowed_entry = re.findall('^(\d+)(|w|m|y)$', self._expiration_time)
        if not allowed_entry:
            raise UsageError("Key expiration option: %s is not valid" % self._expiration_time)
970479
public void removeAll()
    {
        if (m_aRecords != null)
        {
            for (int iArrayIndex = 0; iArrayIndex < MAX_RECORD_ARRAY_SIZE; iArrayIndex++)
            {   // Free the objects that are no longer used
                this.freeElement(m_aRecords[iArrayIndex]);
                m_aRecords[iArrayIndex] = null;
            }
            m_aRecords = null;
        }
        m_iRecordListStep = 1;
        m_iRecordListEnd = 0;
        m_iRecordListMax = 0; // Current size of the record list (records scanned) (-1 - unknown)
    }
822009
private void removeExpiredQueries()
    {
        DateTime timeHorizon = DateTime.now().minus(minQueryExpireAge.toMillis());

        // we're willing to keep queries beyond timeHorizon as long as we have fewer than maxQueryHistory
        while (expirationQueue.size() > maxQueryHistory) {
            T query = expirationQueue.peek();
            if (query == null) {
                return;
            }

            // expirationQueue is FIFO based on query end time. Stop when we see the
            // first query that's too young to expire
            Optional<DateTime> endTime = query.getEndTime();
            if (!endTime.isPresent()) {
                // this shouldn't happen but it is better to be safe here
                continue;
            }
            if (endTime.get().isAfter(timeHorizon)) {
                return;
            }

            // only expire them if they are older than minQueryExpireAge. We need to keep them
            // around for a while in case clients come back asking for status
            QueryId queryId = query.getQueryId();

            log.debug("Remove query %s", queryId);
            queries.remove(queryId);
            expirationQueue.remove(query);
        }
    }
276937
def maybe_clean(self):
        """"""

        now = time.time()
        if self.next_cleaning <= now:
            keys_to_delete = []
            for (k, v) in self.data.iteritems():
                if v.expiration <= now:
                    keys_to_delete.append(k)
            for k in keys_to_delete:
                del self.data[k]
            now = time.time()
            self.next_cleaning = now + self.cleaning_interval
1193846
def clear(self):
        
        self._filters = []
        self._order_by = OrderedDict()
        self._selects = set()
        self._negation = False
        self._attribute = None
        self._chain = None
        self._search = None

        return self
3274
int removeExpired(TimeoutHandler expireHandler)
    {
        // ensure the clock never goes backwards
        long t = ticker.currentTimeMillis();

        int expired = 0;
        for (int i = 0; i < slotCount; i++)
        {
            expired += slots[i].removeExpired(t, expireHandler);
        }
        return expired;
    }
1047645
@Override
	public void removeByLtE_S(Date expirationDate, int status) {
		for (CommerceDiscount commerceDiscount : findByLtE_S(expirationDate,
				status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) {
			remove(commerceDiscount);
		}
	}
292581
def delete_filter_rule(self, _filter, way='in'):
        
        updated_rules = []
        rules = self.get_filter_rules(way=way)

        if isinstance(_filter, zobjects.FilterRule):
            _filter = _filter.name

        if rules:
            for rule in rules:
                if not rule.name == _filter:
                    updated_rules.append(rule)

        if rules != updated_rules:
            content = {
                'filterRules': {
                    'filterRule': [f._full_data for f in updated_rules]
                }
            }
            if way == 'in':
                self.request('ModifyFilterRules', content)
            elif way == 'out':
                self.request('ModifyOutgoingFilterRules', content)

        return updated_rules
353542
def clear(self):
        

        if self._formats:
            for fmt in self._formats:
                fmt.clear()
        self._formats = None
62095
def purge_obsolete_samples(self, config, now):
        
        expire_age = config.samples * config.time_window_ms
        for sample in self._samples:
            if now - sample.last_window_ms >= expire_age:
                sample.reset(now)
631667
public function clear()
    {
        $currentDate = new DateTime();
        foreach (\array_keys(self::$registry) as $key) {
            $this->clearExpiredKey($key, $currentDate);
        }
    }
475417
def cleanup(self):
        
        for dict in (self.rule2func, self.rules, self.rule2name):
            for i in list(dict.keys()):
                dict[i] = None
        for i in dir(self):
            setattr(self, i, None)
266842
def trim(self):
        ''''''
        now_time = time.time()

        while self._seq and self._seq[0].expire_time < now_time:
            item = self._seq.popleft()
            del self._map[item.key]

        if self._max_items:
            while self._seq and len(self._seq) > self._max_items:
                item = self._seq.popleft()
                del self._map[item.key]
119541
def cleanup(self, timeout):
        '''
        
        '''
        cutoff = time() - timeout
        self.collection.remove({_atime: {'$lt': cutoff}})