Webiny\Component\Mongo\Mongo::findOne PHP Method

findOne() public method

public findOne ( $collectionName, $filter = [], array $options = [] )
$options array
    public function findOne($collectionName, $filter = [], array $options = [])
    {
        return $this->bridge->findOne($this->cName($collectionName), $filter, $options);
    }

Usage Example

Esempio n. 1
0
File: Mongo.php Progetto: webiny/hrc
 /**
  * Read the cache for the given key.
  *
  * @param string $key Cache key
  *
  * @return string|bool Cache content, or bool false if the key is not found in the cache.
  */
 public function read($key)
 {
     $result = $this->mongoInstance->findOne(self::collection, ['key' => $key]);
     if (is_array($result) && isset($result['content'])) {
         $this->remainingTtl = $result['ttl']->toDateTime()->getTimestamp() - time();
         return $result['content'];
     }
     $this->remainingTtl = 0;
     return false;
 }
All Usage Examples Of Webiny\Component\Mongo\Mongo::findOne