/*!
Fetch limitation array()

\param use limitation cache, true by default.
483938
function limitationList( $useCache = true, $ignoreLimitIdentifier = false )
    {
        if ( !isset( $this->Limitations ) || !$useCache )
        {

            $limitations = eZPersistentObject::fetchObjectList( eZPolicyLimitation::definition(),
                                                                 null, array( 'policy_id' => $this->attribute( 'id') ), null, null,
                                                                 true );

            eZDebugSetting::writeDebug( 'kernel-policy-limitation', $limitations, "before policy limitations " . $this->ID );
            eZDebugSetting::writeDebug( 'kernel-policy-limitation', $this, "policy itself before before limitations check"  );

            if ( $ignoreLimitIdentifier === false  && isset( $this->LimitIdentifier ) && $this->LimitIdentifier )
            {
                $limitIdentifier =  $this->attribute( 'limit_identifier' );
                $limitValue = $this->attribute( 'limit_value' );
                $limitationTouched = false;
                $checkEmptyLimitation = true;
                foreach ( $limitations as $limitation )
                {
                    if ( $limitation->attribute( 'identifier' ) == $limitIdentifier )
                    {
                        if ( $limitIdentifier == 'Subtree' )
                        {
                            $limitationTouched = true;

                            $values = $limitation->attribute( 'values' );

                            foreach ( $values as $limitationValue )
                            {
                                $value = $limitationValue->attribute( 'value' );
                                if ( strpos( $value, $limitValue ) === 0 )
                                {
                                    $checkEmptyLimitation = false;
                                    eZDebugSetting::writeDebug( 'kernel-policy-limitation', $value,
                                                                "Limitationvalue has been left in the limitation [limitValue=$limitValue]" );
                                }
                                else if ( strpos( $limitValue, $value ) === 0 )
                                {
                                    $checkEmptyLimitation = false;
                                    $limitationValue->setAttribute( 'value', $limitValue );
                                    eZDebugSetting::writeDebug(  'kernel-policy-limitation',
                                                                 $value,
                                                                 "Limitationvalue has been exchanged to the value from cond assignment [limitValue=$limitValue]" );
                                }
                                else
                                {
                                    eZDebugSetting::writeDebug(  'kernel-policy-limitation',  $value,
                                                                 "Limitationvalue has been removed from limitation [limitValue=$limitValue]" );
                                    //exlude limitation value from limitation..
                                    unset( $limitationValue );
                                }
                            }
                            if ( $checkEmptyLimitation )
                            {
                                eZDebugSetting::writeDebug( 'kernel-policy-limitation', $this, 'The policy has been disabled' );
                                $this->Disabled = true;
                                $this->Limitations = array();
                                return $this->Limitations;
                            }
                        }
                    }
                }

                if ( !$limitationTouched )
                {
                    $policyLimitation = new eZPolicyLimitation( array ( 'id' => -1,
                                                                        'policy_id' => $this->attribute( 'id' ),
                                                                        'identifier' => $this->attribute( 'limit_identifier' ) ) );
                    $policyLimitation->setAttribute( 'limit_value', $this->attribute( 'limit_value' ) );

                    $limitations[] = $policyLimitation;
                }
            }
            eZDebugSetting::writeDebug( 'kernel-policy-limitation', $limitations, "policy limitations " . $this->ID );

            $this->Limitations = $limitations;
        }
        return $this->Limitations;
    }
846206
public function getLimitationArrayWithIdentifiers(Limitation $limitation)
    {
        $retValues = array();
        $values = $limitation->limitationValues;

        switch ($limitation->getIdentifier()) {
            case 'Section':
            case 'NewSection':
                foreach ($values as $value) {
                    $section = $this->sectionMatcher->matchOneByKey($value);
                    $retValues[] = $section->identifier;
                }
                break;
            case 'SiteAccess':
                foreach ($values as $value) {
                    $name = "No/unknown SiteAccess Found";
                    if (array_key_exists($value, $this->siteAccessList)) {
                        $name = $this->siteAccessList[$value];
                    }
                    $retValues[] = $name;
                }
                break;
            case 'ParentClass':
            case 'Class':
                foreach ($values as $value) {
                    $contentType = $this->contentTypeMatcher->matchOneByKey($value);
                    $retValues[] = $contentType->identifier;
                }
                break;
            default:
                $retValues = $values;
        }

        return array(
            'identifier' => $limitation->getIdentifier(),
            'values' => $retValues
        );
    }
984508
function memoryLimitRequirement()
    {
        $memoryLimit = ini_get('memory_limit');
        $bytes = $this->getByteSize($memoryLimit);

        $humanLimit = $memoryLimit . ($memoryLimit === -1 ? ' (no limit)' : '');
        $memo = "Craft requires a minimum PHP memory limit of 256M. The memory_limit directive in php.ini is currently set to {$humanLimit}.";

        return array(
            'name' => 'Memory Limit',
            'mandatory' => false,
            'condition' => $bytes === -1 || $bytes >= 268435456,
            'memo' => $memo,
        );
    }
780786
public function many(string $condition = '', array $params = array(), $offset = null, $limit = null) {
        X::logger()->trace('Redis cached many');
        $key = $this->getManyKey($condition, $params, $offset, $limit);
        /** @var array $pks */
        /** @noinspection UnserializeExploitsInspection */
        $pks = @unserialize($this->redis()->get($key));
        if (is_array($pks)) {
            X::logger()->trace("Hit many $key");
            return $this->pks2models($pks);
        }

        X::logger()->trace("Miss many $key");
        return $this->manySet($key,
            DirectModelManager::getInstance($this->model)
                ->many($condition, $params, $offset, $limit)
        );
    }
368109
protected function _getLimit($key = null, $default = null) {
		$result = (int)$default;
		if (empty($key)) {
			return $result;
		}

		$data = $this->getConfig('LdapSync.Limits.' . $key);
		if (($data === null) || !is_int($data)) {
			return $result;
		}

		$data = (int)$data;
		if ($data < 0) {
			return $result;
		}

		return $data;
	}
790304
protected function fetch($limit = null, $offset = null)
    {
        if (is_int($limit)) {
            $this->statement->limit($limit, $offset);
        }

        $statement = $this->statement->execute();

        if ($this->model instanceof Models) {
            $statement->setFetchMode(\PDO::FETCH_INTO, $this->model);
        } else {
            $statement->setFetchMode(\PDO::FETCH_CLASS|\PDO::FETCH_PROPS_LATE, $this->model);
        }

        return $statement;
    }
1183640
protected function buildLimit(
        /*# string */ $prefix,
        array $settings
    )/*# : string */ {
        $result = [];
        $clause = &$this->getClause('LIMIT');
        if (!empty($clause)) {
            $res = [];
            if ($clause[0]) {
                $res[] = $clause[0];
            }
            if ($clause[1]) {
                $res[] = 'OFFSET ' . $clause[1];
            }
            $result[] = join(' ', $res);
        }
        return $this->joinClause($prefix, ' ', $result, $settings);
    }
1312054
protected function fetch($fields=[], $limit=NULL, $order=NULL, $offset=NULL, &$count=FALSE)
    {
        if ($limit == self::FETCH_COUNT) {
            return $this->getCount($fields);
        }
        $data = $this->getDataList($fields, $limit, $order, $offset, $count !== FALSE);
        if ($count !== FALSE) {
            $count = $this->fetchCount();
        }
        return $this->resultAsModelList($data);
    }
396208
public function get($limit = null, $offset = null)
    {
        if (isset($limit)) {
            $this->limit($limit, $offset);
        }

        if (false !== ($result = $this->conn->query($this->builderCache))) {
            $result->setTotalRows($this->countAllResults(true));
        }

        $this->builderCache->reset();

        return $result;
    }
1241931
static function fetchByConds( $params )
    {
        /**
         * Conditions possible in $param (array hash):
         *   int 'contentobject_id'
         *   int 'contentobject_attribute_id'
         *   int 'user_id'
         *   string 'session_key'
         *   bool 'as_object' By default: true
         *
         *   Conditions can be combined as you wish,
         */
        $conds = array();
        $limit = null;
        $sorts = array();
        $asObject = isset( $params['as_object'] ) ? $params['as_object'] : true;

        if ( isset( $params['contentobject_id'] ) )
        {
            $conds['contentobject_id'] = $params['contentobject_id'];
        }
        else if ( isset( $params['object_id'] ) )// Alias
        {
            $conds['contentobject_id'] = $params['object_id'];
        }

        if ( isset( $params['contentobject_attribute_id'] ) )
        {
            if ( !isset( $conds['contentobject_id'] ) ) $conds['contentobject_id'] = array( '!=', 0 );// to make sure index is used
            $conds['contentobject_attribute_id'] = $params['contentobject_attribute_id'];
        }

        if ( isset( $params['user_id'] ) )
        {
            $conds['user_id'] = $params['user_id'];
        }

        if ( isset( $params['session_key'] ) )
        {
            if ( !isset( $conds['user_id'] ) ) $conds['user_id'] = array( '!=', 0 );// to make sure index is used
            $conds['session_key'] = $params['session_key'];
        }

        if ( isset( $params['limit'] ) )
        {
            $limit = array( 'length' => $params['limit'], 'offset' => (isset( $params['offset'] ) ? $params['offset'] : 0 ) );
        }
        else if ( isset( $params['offset'] ) )
        {
            $limit = array( 'offset' =>  $params['offset'] );
        }

        if ( isset( $params['sort_by'] ) )
        {
            if ( isset( $params['sort_by'][1] ) && is_array( $params['sort_by'] ) )
                $sorts = array( $params['sort_by'][0] => ( $params['sort_by'][1] ? 'asc' : 'desc' ) );
            else
                $sorts[ $params['sort_by'] ] = 'asc';
        }

        $rows = eZPersistentObject::fetchObjectList( self::definition(), null, $conds, $sorts, $limit, $asObject );

        if ( $rows === null )
        {
            eZDebug::writeError( 'The ezstarrating table seems to be missing,
                                  contact your administrator', __METHOD__ );
            return false;
        }
        return $rows;
    }
1267010
protected function setFetchOptions(&$fetch, $limit, $order, $offset)
    {
        if (!is_null($limit)) {
            $fetch->limit($limit);
        }
        if (!is_null($offset)) {
            $fetch->offset($offset);
        }
        if (!is_null($order)) {
            $fetch->clearOrderBy($order);
            if (is_array($order)) {
                $fetch->order($order[0], $order[1]);
            } else {
                $fetch->order($order);
            }
        }
        return $fetch;
    }
770084
public function fetchCachedRequest()
    {
        Deprecated::method(3.3);

        $response = false;
        if ($this->checkCacheConditions('request', true)) {
            $key = md5($this->app['request']->getPathInfo() . $this->app['request']->getQueryString());

            $result = $this->app['cache']->fetch($key);

            // If we have a result, prepare a Response.
            if (!empty($result)) {
                $response = new Response($result, Response::HTTP_OK);

                // Note that we set the cache-control header to _half_ the
                // maximum duration, otherwise a proxy/cache might keep the
                // cache twice as long in the worst case scenario, and now it's
                // only 50% max, but likely less
                // 's_maxage' sets the cache for shared caches.
                // max_age sets it for regular browser caches

                $age = $this->cacheDuration() / 2;

                $response->setMaxAge($age)->setSharedMaxAge($age);
            }
        }

        return $response;
    }
26063
public function request($function, array $params = array(), $cache = null)
    {
        $request = $this->startRequest($function, $params, $cache);

        return $this->fetchResponse($request);
    }
1081511
def fetch(self, limit, offset=0):
        """"""
        self.limit = limit
        self.offset = offset
        return self
398760
public function fetch($key)
    {
        if(extension_loaded('apcu') && function_exists('apcu_fetch')) {
            $cached = apcu_fetch($key);
            if (!$cached) {
                return null;
            }

            return $cached;

        }else{
            return null;
        }
    }
1086616
def inheritable_cache_get(formats, name, partial, param)
      prefixes = formats.collect { |format| inheritable_cache[format.to_sym][partial][name][param] }
      prefixes.compact!
      prefixes.empty? ?  nil : prefixes.first
    end
326901
public function canFullRefuse()
    {
        if (!is_numeric($this->last_expires)) {
            return null; // In case server is not sold
        }

        return (time() - Yii::$app->formatter->asTimestamp($this->last_expires)) / 3600 / 24 < 5;
    }