diff options
author | xue <> | 2005-11-19 04:35:07 +0000 |
---|---|---|
committer | xue <> | 2005-11-19 04:35:07 +0000 |
commit | 8fd040ef49321fce9d3d0b9c44937984a2112b52 (patch) | |
tree | 573dcfe6a3ec6d5a3b7fde9298dcc1b4f45116b1 /framework/Data | |
parent | bc1a7e1e3a67537189d30013ea6d5fa4bf98e8e4 (diff) |
Diffstat (limited to 'framework/Data')
-rw-r--r-- | framework/Data/TMemCache.php | 10 | ||||
-rw-r--r-- | framework/Data/TSqliteCache.php | 21 |
2 files changed, 23 insertions, 8 deletions
diff --git a/framework/Data/TMemCache.php b/framework/Data/TMemCache.php index 9786b467..b78014fb 100644 --- a/framework/Data/TMemCache.php +++ b/framework/Data/TMemCache.php @@ -49,6 +49,14 @@ * $object2=$cache->get('object');
* </code>
*
+ * If loaded, TMemCache will register itself with {@link TApplication} as the
+ * cache module. It can be accessed via {@link TApplication::getCache()}.
+ *
+ * TMemCache may be configured in application configuration file as follows
+ * <module id="cache" type="System.Data.TMemCache" Host="localhost" Port=11211 />
+ * where {@link getHost Host} and {@link getPort Port} are configurable properties
+ * of TMemCache.
+ *
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
* @package System.Data
@@ -107,7 +115,7 @@ class TMemCache extends TComponent implements IModule, ICache throw new TConfigurationException('memcache_extension_required');
$this->_cache=new Memcache;
if($this->_cache->connect($this->_host,$this->_port)===false)
- throw new TInvalidConfigurationException('memcache_connection_failed');
+ throw new TInvalidConfigurationException('memcache_connection_failed',$this->_host,$this->_port);
if($application instanceof TApplication)
$this->_prefix=$application->getUniqueID();
$this->_initialized=true;
diff --git a/framework/Data/TSqliteCache.php b/framework/Data/TSqliteCache.php index eac22dd2..5eb692d4 100644 --- a/framework/Data/TSqliteCache.php +++ b/framework/Data/TSqliteCache.php @@ -17,7 +17,8 @@ *
* The database file is specified by the DbFile property. This property must
* be set before {@link init} is invoked. If the specified database file does not
- * exist, it will be created automatically. Make sure the database file is writable.
+ * exist, it will be created automatically. Make sure the directory containing
+ * the specified DB file and the file itself must be writable by the Web server process.
*
* The following basic cache operations are implemented:
* - {@link get} : retrieve the value with a key (if any) from cache
@@ -50,6 +51,14 @@ * $object2=$cache->get('object');
* </code>
*
+ * If loaded, TSqliteCache will register itself with {@link TApplication} as the
+ * cache module. It can be accessed via {@link TApplication::getCache()}.
+ *
+ * TMemCache may be configured in application configuration file as follows
+ * <module id="cache" type="System.Data.TSqliteCache" DbFile="Application.Data.site" />
+ * where {@link getDbFile DbFile} is a property specifying the location of the
+ * SQLite DB file (in the namespace format).
+ *
* @author Qiang Xue <qiang.xue@gmail.com>
* @version $Revision: $ $Date: $
* @package System.Data
@@ -113,11 +122,9 @@ class TSqliteCache extends TComponent implements IModule, ICache if(!function_exists('sqlite_open'))
throw new TConfigurationException('sqlitecache_extension_required');
if($this->_file===null)
- throw new TConfigurationException('sqlitecache_filename_required');
+ throw new TConfigurationException('sqlitecache_dbfile_required');
$error='';
- if(($fname=Prado::getPathOfNamespace($this->_file,self::DB_FILE_EXT))===null)
- throw new TConfigurationException('sqlitecache_dbfile_invalid',$this->_file);
- if(($this->_db=new SQLiteDatabase($fname,0666,$error))===false)
+ if(($this->_db=new SQLiteDatabase($this->_file,0666,$error))===false)
throw new TConfigurationException('sqlitecache_connection_failed',$error);
if(($res=$this->_db->query('SELECT * FROM sqlite_master WHERE tbl_name=\''.self::CACHE_TABLE.'\' AND type=\'table\''))!=false)
{
@@ -166,8 +173,8 @@ class TSqliteCache extends TComponent implements IModule, ICache {
if($this->_initialized)
throw new TInvalidOperationException('sqlitecache_dbfile_unchangeable');
- else
- $this->_file=$value;
+ else if(($this->_file=Prado::getPathOfNamespace($value,self::DB_FILE_EXT))===null)
+ throw new TConfigurationException('sqlitecache_dbfile_invalid',$value);
}
/**
|