protected function storeItemInCache($key, CacheItemInterface $item, $ttl) { $object = ['_id' => $key, 'data' => serialize($item->get())]; if ($ttl) { $object['expiresAt'] = new UTCDateTime((time() + $ttl) * 1000); } $this->collection->updateOne(['_id' => $key], ['$set' => $object], ['upsert' => true]); return true; }