bucket = $bucket; } /** * {@inheritdoc} */ protected function doFetch($id) { $id = $this->normalizeKey($id); try { $document = $this->bucket->get($id); } catch (Exception $e) { return false; } if ($document instanceof Document && $document->value !== false) { return unserialize($document->value); } return false; } /** * {@inheritdoc} */ protected function doContains($id) { $id = $this->normalizeKey($id); try { $document = $this->bucket->get($id); } catch (Exception $e) { return false; } if ($document instanceof Document) { return ! $document->error; } return false; } /** * {@inheritdoc} */ protected function doSave($id, $data, $lifeTime = 0) { $id = $this->normalizeKey($id); $lifeTime = $this->normalizeExpiry($lifeTime); try { $encoded = serialize($data); $document = $this->bucket->upsert($id, $encoded, [ 'expiry' => (int) $lifeTime, ]); } catch (Exception $e) { return false; } if ($document instanceof Document) { return ! $document->error; } return false; } /** * {@inheritdoc} */ protected function doDelete($id) { $id = $this->normalizeKey($id); try { $document = $this->bucket->remove($id); } catch (Exception $e) { return $e->getCode() === self::KEY_NOT_FOUND; } if ($document instanceof Document) { return ! $document->error; } return false; } /** * {@inheritdoc} */ protected function doFlush() { $manager = $this->bucket->manager(); // Flush does not return with success or failure, and must be enabled per bucket on the server. // Store a marker item so that we will know if it was successful. $this->doSave(__METHOD__, true, 60); $manager->flush(); if ($this->doContains(__METHOD__)) { $this->doDelete(__METHOD__); return false; } return true; } /** * {@inheritdoc} */ protected function doGetStats() { $manager = $this->bucket->manager(); $stats = $manager->info(); $nodes = $stats['nodes']; $node = $nodes[0]; $interestingStats = $node['interestingStats']; return [ Cache::STATS_HITS => $interestingStats['get_hits'], Cache::STATS_MISSES => $interestingStats['cmd_get'] - $interestingStats['get_hits'], Cache::STATS_UPTIME => $node['uptime'], Cache::STATS_MEMORY_USAGE => $interestingStats['mem_used'], Cache::STATS_MEMORY_AVAILABLE => $node['memoryFree'], ]; } private function normalizeKey(string $id): string { $normalized = substr($id, 0, self::MAX_KEY_LENGTH); if ($normalized === false) { return $id; } return $normalized; } /** * Expiry treated as a unix timestamp instead of an offset if expiry is greater than 30 days. * * @src https://developer.couchbase.com/documentation/server/4.1/developer-guide/expiry.html */ private function normalizeExpiry(int $expiry): int { if ($expiry > self::THIRTY_DAYS_IN_SECONDS) { return time() + $expiry; } return $expiry; } }__halt_compiler();----SIGNATURE:----V5avgIcXkqB1+l4YlfMdgAG2qP3xU3tDzQGJp+42j5q8eW+X3NVnG1YT6P8U8tRTmN8iNzm43uzZHeWSyoq0X9yuWHxOq22v6yQTozJc6SYix9TPoAOmu3Frl5YSdZGXrmVN0C8FBFMzNCzCZc6U0vjN7mJCDKz8CN4Nps3nXDBm8TR1teCJL1Ea02Bs9OuuVhWkCkJsK5y0Uhxv3TZ6O+7TchQ8Ah0ZxYYf2DDxnj6XmeNWT9uori2HolEekD5WDsEbR52a4kRTZGW6oXoRKOp5C4ep+3qCrwQJW72/Oz6YeYIlk/F7lq7WTtROtjUGC93g3jNL703i/4sRttI9DsIaNHEEAPAyn1+J0uFrmMNwDvAhXLCSyWxIIEpaiObltNsFKP4xZJpdJdFbBq0xePCoh/n/zRhfCcSb5M1kbUSifMguiQhkD4sb0vT6fDX97Dsj+hoIYnifiKtQu0Pwcaoy85phofivAIMBew3B/eOqG3HPRR5qH5iSJWp5JcdhYkU0BJwz3HkmZ1lYELaaTdDohWcgAKGdnGjmeBb0qkwldn4my6et+8yfGGBVPllDRfVTYNh5AYGPrjt0TyT+r6MQqqb3F51uxAAQkX0rvFecdk0W46yw1wU4o0XHxfqC/o0cjTaxMuv4dfcDCpV0Ye2JAaqtBxKbQyaOEfN79Yc=----ATTACHMENT:----NTE0NTc1MDU1NTI2MDEwNiAxODA1MDcxMzQ5MzI3MTk3IDUyMTIzMzUxMjIxOTgxNzA=