PHP code example of oanhnn / cache

1. Go to this page and download the library: Download oanhnn/cache library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

oanhnn / cache example snippets


    var $actsAs = array(
        'Cache.Cached'
    );

    /**
     * @var array Using Behavior
     */
    public $actsAs = array(
        'Cache.Cached' => array(
            'config' => '_cake_queries_',
            'map' => '_cake_queries_map_',
            'clearOnDelete' => true,
            'clearOnSave' => true,
            'auto' => true,
            'gzip' => false,
        ),
    );

    // cache the results of this query for a day
    $this->Post->find('all', array(
		  'conditions' => array('Post.name LIKE' => '%awesome%'),
		  'cache' => array(
                'config'   => '_cake_queries_',
                'gzip'     => false,
                'key'      => 'key_of_cache',
                'duration' => '+1 days'
       ),
    ));
    // don't cache the results of this query at all
    $this->Post->find('all', array(
		  'conditions' => array('Post.name LIKE' => '%lame%'),
		  'cache' => false
    ));
    // cache using the default settings even if auto = false
    $this->Post->find('all', array(
		  'conditions' => array('Post.name LIKE' => '%okay i guess%'),
		  'cache' => true
    ));