Created
January 20, 2015 13:37
-
-
Save chukShirley/35c693666955fe149b69 to your computer and use it in GitHub Desktop.
Zend Data Cache
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ItemsGateway extends AbstractGateway | |
{ | |
protected $table = 'SCF906'; | |
public function fetchAll() | |
{ | |
// Try to fetch from the cache first | |
$response = zend_shm_cache_fetch('itemCodes'); | |
// If itemCodes list isn't in cache | |
if ($response === false){ | |
$sql = "SELECT * FROM ".$this->table; | |
$stmt = $this->db->query($sql,[]); | |
$response = []; | |
while ($row = db2_fetch_assoc($stmt)) | |
{ | |
$response[] = array_map('trim',$row); | |
} | |
// Store the results in cache | |
zend_shm_cache_store('itemCodes',$response,24*3600); | |
} | |
return $response; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment