DB\Mongo\Mapper::count PHP Метод

count() публичный Метод

Count records that match criteria
public count ( $filter = NULL, $ttl ) : integer
$filter array
$ttl int
Результат integer
    function count($filter = NULL, $ttl = 0)
    {
        $fw = \Base::instance();
        $cache = \Cache::instance();
        if (!($cached = $cache->exists($hash = $fw->hash($fw->stringify([$filter])) . '.mongo', $result)) || !$ttl || $cached[0] + $ttl < microtime(TRUE)) {
            $result = $this->collection->count($filter ?: []);
            if ($fw->get('CACHE') && $ttl) {
                // Save to cache backend
                $cache->set($hash, $result, $ttl);
            }
        }
        return $result;
    }