Utility method to reduce code duplication.

@param string $key
Key to store the evet counters in.

@return bool
True on success, false otherwise.
19860
private function recordEvent($key)
    {
        $success = null;
        apcu_inc($key, 1, $success);
        if ($success !== null && !$success) {
            // @TODO: Remove this fallback when we drop APCu 4.x support.
            // @codeCoverageIgnoreStart
            // Ignore coverage because (1) it's tested with other code and
            // (2) APCu 5.x does not use it.
            $success = apcu_store($key, 1);
            // @codeCoverageIgnoreEnd
        }
        return $success;
    }
722205
public function decr($key)
    {
        if ($this->isMappedKey($key)) {
            return false;
        }
        return $this->getDriver()->decr($key);
    }
1290104
public function hasStored(string $key)
    {
        if (isset($this->store[$key])) {
            return true;
        }

        if (isset($this->aliases[$key])) {
            return isset($this->store[$this->aliases[$key]]);
        }

        return false;
    }
970235
public function __isset($key)
    {
        $k = strtolower($key);
        //check for specialised discovery method
        $methodName = 'has' . ucfirst($k);
        if (method_exists($this, $methodName)) {
            return $this->$methodName();
        } elseif (array_key_exists($k, $this->buildItems) && !is_null($this->buildItems[$k])) {
            return true;
        }
        
        return false;
    }
41403
public function sFlush($key) {
        $this->_redis->multi();
        $this->_redis->sMembers($key);
        $this->_redis->del($key);
        return $this->_redis->exec()[0];
    }
190521
public function count($key)
    {
        $key = $key instanceof UnitOfTimeInterface ? $this->prefixKey . $key->getKey() : $this->prefixTempKey . $key;

        return (int) $this->getRedisClient()->bitcount($key);
    }
468736
public function offsetExists($key)
    {
        $langs = Languages::getInstance($this->getCategory());
        return isset($langs[$this->code][$key]);
    }
1249582
public function is($key) {
        $code = $this->current()->getCode();

        return ($code === $key || $this->canonicalize($code) === $key);
    }
494372
public function keyExists(string $key): bool
    {
        $result = $this->database->prepare('SELECT * FROM tl_db_cache WHERE cacheKey = ?')->execute($key);

        return $result->numRows > 0;
    }
123835
public function addKey( $key )
	{
		if( is_array( $key ) )
			return $this->addKeys( $key );
		if( in_array( $key, $this->keys ) )
			return FALSE;
		$this->keys[] = $key;
		return TRUE;
	}
525945
public function delete($key) {
        if (!isset($this->store[$key])) {
            return false;
        }
        unset($this->store[$key]);
        if ($this->maxsize !== false) {
            $this->storecount--;
        }
        return true;
    }
1092040
public function remove($key): bool
    {
        $removed = false;
        $bucket = $this->locate($key);

        if ($bucket !== null) {
            $this->removeBucket($bucket);
            $this->rewind();
            $removed = true;
        }

        return $removed;
    }
818496
public function has($key)
    {
        // Got help from here: http://stackoverflow.com/a/3091136/1208233
        if (!$this->memcached->add($key, true, 10)) {
            // If not possible to add, then the key exists
            return true;
        } else {
            // If possible to add, then the key doesn't exist
            $this->memcached->delete($key);
            return false;
        }
    }
287853
public function offsetExists($key)
    {
        if (is_integer($key) && $key + 1 <= $this->count()) {
            return true;
        }

        return $this->has($key);
    }
266238
public function exists(?string $key = null) : bool
    {
        $key = $this->constructKey($key);

        return $this->parseKey($key, function ($part, $result) {
            return array_key_exists($part, $result);
        });
    }
720766
public function has($key)
    {
        // For performance, we can use isset,
        // but it will not match if value == 0
        return isset($this->values[$key]) || array_key_exists($key, $this->values);
    }
1207867
public function has(string $key): bool
    {
        $this->assertRead();

        return \array_key_exists($key, $this->data);
    }