Return to Snippet

Revision: 28104
at June 30, 2010 22:31 by orenus


Initial Code
//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..."
	}
}

Initial URL

                                

Initial Description

                                

Initial Title
Get Weather - Step 8 - Adding Abstraction. Pt 2.

Initial Tags
php

Initial Language
PHP