public function get($key) { // Get document $document = $this->collection->getDocument($key); if (!$document) { return null; } // Mongo deletes document not exactly when set in field // Required date checking // Expiration may be empty for keys whicj never expired $expiredAt = $document->get(self::FIELD_NAME_EXPIRED); if ($expiredAt && $expiredAt->sec < time()) { return null; } // Return value return $document->get(self::FIELD_NAME_VALUE); }
public function testDelete() { $this->cache->set('php', 'PHP: Hypertext Processor', 1); $this->assertEquals('PHP: Hypertext Processor', $this->cache->get('php')); $this->cache->delete('php'); $this->assertEmpty($this->cache->get('php')); }