summaryrefslogtreecommitdiff
path: root/framework/Data
diff options
context:
space:
mode:
authorxue <>2005-12-28 20:17:54 +0000
committerxue <>2005-12-28 20:17:54 +0000
commite8b60312037e54c34a06d6f57d7c21946cf3cd1f (patch)
treea6f35f5d4bb921998ca306602a33fc03ba47c4b5 /framework/Data
parent930c51a6d618d487105cd46c517f36c3b1fe3b44 (diff)
Modified the way to access application singleton.
IService and IModule interfaces are also adjusted accordingly.
Diffstat (limited to 'framework/Data')
-rw-r--r--framework/Data/TMemCache.php11
-rw-r--r--framework/Data/TSqliteCache.php11
2 files changed, 10 insertions, 12 deletions
diff --git a/framework/Data/TMemCache.php b/framework/Data/TMemCache.php
index e4e9ffa3..a34cd9a6 100644
--- a/framework/Data/TMemCache.php
+++ b/framework/Data/TMemCache.php
@@ -44,7 +44,7 @@
* Some usage examples of TMemCache are as follows,
* <code>
* $cache=new TMemCache; // TMemCache may also be loaded as a Prado application module
- * $cache->init(null);
+ * $cache->init();
* $cache->add('object',$object);
* $object2=$cache->get('object');
* </code>
@@ -105,19 +105,18 @@ class TMemCache extends TModule implements ICache
* @param TXmlElement configuration for this module, can be null
* @throws TConfigurationException if memcache extension is not installed or memcache sever connection fails
*/
- public function init($application,$config)
+ public function init($config=null)
{
- parent::init($application,$config);
+ parent::init($config);
if(!extension_loaded('memcache'))
throw new TConfigurationException('memcache_extension_required');
$this->_cache=new Memcache;
if($this->_cache->connect($this->_host,$this->_port)===false)
throw new TConfigurationException('memcache_connection_failed',$this->_host,$this->_port);
- if($application instanceof TApplication)
- $this->_prefix=$application->getUniqueID();
+ $this->_prefix=$this->getApplication()->getUniqueID();
$this->_initialized=true;
- $application->setCache($this);
+ $this->getApplication()->setCache($this);
}
/**
diff --git a/framework/Data/TSqliteCache.php b/framework/Data/TSqliteCache.php
index 865c2a47..d2955ccd 100644
--- a/framework/Data/TSqliteCache.php
+++ b/framework/Data/TSqliteCache.php
@@ -47,7 +47,7 @@
* <code>
* $cache=new TSqliteCache; // TSqliteCache may also be loaded as a Prado application module
* $cache->setDbFile($dbFilePath);
- * $cache->init(null);
+ * $cache->init();
* $cache->add('object',$object);
* $object2=$cache->get('object');
* </code>
@@ -109,19 +109,18 @@ class TSqliteCache extends TModule implements ICache
* property is set, and creates a SQLiteDatabase instance for it.
* The database or the cache table does not exist, they will be created.
* Expired values are also deleted.
- * @param TApplication Prado application, can be null
* @param TXmlElement configuration for this module, can be null
* @throws TConfigurationException if sqlite extension is not installed,
* DbFile is set invalid, or any error happens during creating database or cache table.
*/
- public function init($application,$config)
+ public function init($config=null)
{
- parent::init($application,$config);
+ parent::init($config);
if(!function_exists('sqlite_open'))
throw new TConfigurationException('sqlitecache_extension_required');
if($this->_file===null)
- $this->_file=$application->getRuntimePath().'/sqlite.cache';
+ $this->_file=$this->getApplication()->getRuntimePath().'/sqlite.cache';
$error='';
if(($this->_db=new SQLiteDatabase($this->_file,0666,$error))===false)
throw new TConfigurationException('sqlitecache_connection_failed',$error);
@@ -137,7 +136,7 @@ class TSqliteCache extends TModule implements ICache
throw new TConfigurationException('sqlitecache_table_creation_failed',sqlite_error_string(sqlite_last_error()));
$this->_db->query('DELETE FROM '.self::CACHE_TABLE.' WHERE expire<>0 AND expire<'.time());
$this->_initialized=true;
- $application->setCache($this);
+ $this->getApplication()->setCache($this);
}
/**