PHP code example of cyber-duck / cacheing-memoizer
1. Go to this page and download the library: Download cyber-duck/cacheing-memoizer 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' );
cyber-duck / cacheing-memoizer example snippets
public function getPackageAttribute ()
{
return $this ->memoize('package' ,
function () {
return package()->create(['code' => $this ->PackageTypeCode]);
});
}
public function find_all ($params = array() , $skip = array('page' , 'limit' , 'sort-by' ) )
{
$this ->db->select('waOrg.OrgID, waOrg.OrgName, waOrg.PackageTypeCode, waOrg.HasGallery, waOrg.HasShowReel, waOrg.AllowSearchResultsPageLogo' );
$this ->db->join($this ->dbn.'[wlEntry]' , 'wlEntry.OrgID = waOrg.OrgID' );
$this ->db->join($this ->dbn_live.'[wpCountry]' , 'wpCountry.Country = waOrg.Country' , 'left' );
$this ->db->group_by('waOrg.OrgID, waOrg.OrgName, waOrg.PackageTypeCode, waOrg.HasGallery, waOrg.HasShowReel, waOrg.AllowSearchResultsPageLogo' );
$this ->db->distinct();
$this ->_apply_filters($params, $skip);
$query = $this ->db->get($this ->dbn.'[waOrg] waOrg' );
if (count($query->result()) > 0 )
{
return count($query->result());
}
return false ;
}
public function find_all ($params = array() , $skip = array('page' , 'limit' , 'sort-by' ) )
{
return $this ->globallyMemoizeWithCache(['org.find.all' , $params, $skip], function ($params, $skip) {
$this ->db->select('waOrg.OrgID, waOrg.OrgName, waOrg.PackageTypeCode, waOrg.HasGallery, waOrg.HasShowReel, waOrg.AllowSearchResultsPageLogo' );
$this ->db->join($this ->dbn.'[wlEntry]' , 'wlEntry.OrgID = waOrg.OrgID' );
$this ->db->join($this ->dbn_live.'[wpCountry]' , 'wpCountry.Country = waOrg.Country' , 'left' );
$this ->db->group_by('waOrg.OrgID, waOrg.OrgName, waOrg.PackageTypeCode, waOrg.HasGallery, waOrg.HasShowReel, waOrg.AllowSearchResultsPageLogo' );
$this ->db->distinct();
$this ->_apply_filters($params, $skip);
$query = $this ->db->get($this ->dbn.'[waOrg] waOrg' );
if (count($query->result()) > 0 )
{
return count($query->result());
}
return false ;
}, $params, $skip);
}