public function ClearCache(string $keyPattern = NULL)
    {
        if (GnApi::$Debug) {
            GnLogger::Verbose("Clear cache '{$keyPattern}'");
        }

        if (static::$CacheHandler) {
            static::$CacheHandler->deleteKey($keyPattern);
            static::$CacheHandler->deleteGroup($keyPattern);
        } else {
            $keys = $this->_memcached->getAllKeys();
            if (GnUtil::IsNullOrEmpty($keyPattern)) {
                // remove all items
                foreach ($keys as $key) {
                    $this->_memcached->delete($key);
                }
                return;
            }

            // remove key-patterns only
            foreach ($keys as $key) {
                $matches = array();
                $ret = preg_match("/" . preg_quote($keyPattern, '/') . "/", $key, $matches);
                if ($ret > 0) {
                    $this->_memcached->delete($key);
                }
            }
        }
    }