public function index()
    {
        $page = $this->request->getQuery('page', 1);

        $this->paginate['order'] = ['tag' => 'ASC'];

        //Limit X4
        $this->paginate['limit'] = $this->paginate['maxLimit'] = $this->paginate['limit'] * 4;

        //Sets the cache name
        $cache = sprintf('tags_limit_%s_page_%s', $this->paginate['limit'], $page);

        //Tries to get data from the cache
        list($tags, $paging) = array_values(Cache::readMany(
            [$cache, sprintf('%s_paging', $cache)],
            $this->PostsTags->getCacheName()
        ));

        //If the data are not available from the cache
        if (empty($tags) || empty($paging)) {
            $query = $this->PostsTags->Tags->find('active');
            $tags = $this->paginate($query);

            //Writes on cache
            Cache::writeMany([
                $cache => $tags,
                sprintf('%s_paging', $cache) => $this->request->getParam('paging'),
            ], $this->PostsTags->getCacheName());
        //Else, sets the paging parameter
        } else {
            $this->request = $this->request->withParam('paging', $paging);
        }

        $this->set(compact('tags'));
    }
public function index()
    {
        $page = $this->request->getQuery('page', 1);

        $this->paginate['order'] = ['tag' => 'ASC'];

        //Limit X4
        $this->paginate['limit'] = $this->paginate['maxLimit'] = $this->paginate['limit'] * 4;

        //Sets the cache name
        $cache = sprintf('tags_limit_%s_page_%s', $this->paginate['limit'], $page);

        //Tries to get data from the cache
        list($tags, $paging) = array_values(Cache::readMany(
            [$cache, sprintf('%s_paging', $cache)],
            $this->PostsTags->getCacheName()
        ));

        //If the data are not available from the cache
        if (empty($tags) || empty($paging)) {
            $query = $this->PostsTags->Tags->find('active');
            $tags = $this->paginate($query);

            //Writes on cache
            Cache::writeMany([
                $cache => $tags,
                sprintf('%s_paging', $cache) => $this->request->getParam('paging'),
            ], $this->PostsTags->getCacheName());
        //Else, sets the paging parameter
        } else {
            $this->request = $this->request->withParam('paging', $paging);
        }

        $this->set(compact('tags'));
    }
public function index ( ) { $ page = $ this -> request -> getQuery ( 'page' , 1 ) ; $ this -> paginate [ 'order' ] = [ 'tag' => 'ASC' ] ; //Limit X4 $ this -> paginate [ 'limit' ] = $ this -> paginate [ 'maxLimit' ] = $ this -> paginate [ 'limit' ] * 4 ; //Sets the cache name $ cache = sprintf ( 'tags_limit_%s_page_%s' , $ this -> paginate [ 'limit' ] , $ page ) ; //Tries to get data from the cache list ( $ tags , $ paging ) = array_values ( Cache :: readMany ( [ $ cache , sprintf ( '%s_paging' , $ cache ) ] , $ this -> PostsTags -> getCacheName ( ) ) ) ; //If the data are not available from the cache if ( empty ( $ tags ) || empty ( $ paging ) ) { $ query = $ this -> PostsTags -> Tags -> find ( 'active' ) ; $ tags = $ this -> paginate ( $ query ) ; //Writes on cache Cache :: writeMany ( [ $ cache => $ tags , sprintf ( '%s_paging' , $ cache ) => $ this -> request -> getParam ( 'paging' ) , ] , $ this -> PostsTags -> getCacheName ( ) ) ; //Else, sets the paging parameter } else { $ this -> request = $ this -> request -> withParam ( 'paging' , $ paging ) ; } $ this -> set ( compact ( 'tags' ) ) ; }
Lists posts tags
@return void
Lists posts tags