/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
//creating the so called "abstraction" layer...(!!!!) abstract class BaseCache{ public function BaseCache(){ //some intitialization here... } abstract public function set($key, $val); abstract public function get($key); } //no "abstract" key word before class //and before abstract methods (unless...MemCahce was abstract itself...) class MemCache extends BaseCache{ public function set($key, $val){ //... } } class DBCache extends BaseCache{ public function set($key, $val){ // " INSERT INTO my_cache_table (key, val) values ("$key", "$val")..." } public function get($key) { // SELECT key,val from my_cache_table where key=$key..." } }