Öffentliche Methoden | |
nusoap_wsdlcache ($cache_dir='.', $cache_lifetime=0) | |
createFilename ($wsdl) | |
debug ($string) | |
get ($wsdl) | |
obtainMutex ($filename, $mode) | |
put ($wsdl_instance) | |
releaseMutex ($filename) | |
remove ($wsdl) | |
Öffentliche Attribute | |
$fplock | |
$cache_lifetime | |
$cache_dir | |
$debug_str = '' |
Definiert in Zeile 18 der Datei class.wsdlcache.php.
nusoap_wsdlcache::createFilename | ( | $ | wsdl | ) |
creates the filename used to cache a wsdl instance
string | $wsdl The URL of the wsdl instance |
Definiert in Zeile 60 der Datei class.wsdlcache.php.
nusoap_wsdlcache::debug | ( | $ | string | ) |
adds debug data to the class level debug string
string | $string debug data private |
Definiert in Zeile 70 der Datei class.wsdlcache.php.
nusoap_wsdlcache::get | ( | $ | wsdl | ) |
gets a wsdl instance from the cache
string | $wsdl The URL of the wsdl instance |
Definiert in Zeile 81 der Datei class.wsdlcache.php.
00081 { 00082 $filename = $this->createFilename($wsdl); 00083 if ($this->obtainMutex($filename, "r")) { 00084 // check for expired WSDL that must be removed from the cache 00085 if ($this->cache_lifetime > 0) { 00086 if (file_exists($filename) && (time() - filemtime($filename) > $this->cache_lifetime)) { 00087 unlink($filename); 00088 $this->debug("Expired $wsdl ($filename) from cache"); 00089 $this->releaseMutex($filename); 00090 return null; 00091 } 00092 } 00093 // see what there is to return 00094 if (!file_exists($filename)) { 00095 $this->debug("$wsdl ($filename) not in cache (1)"); 00096 $this->releaseMutex($filename); 00097 return null; 00098 } 00099 $fp = @fopen($filename, "r"); 00100 if ($fp) { 00101 $s = implode("", @file($filename)); 00102 fclose($fp); 00103 $this->debug("Got $wsdl ($filename) from cache"); 00104 } else { 00105 $s = null; 00106 $this->debug("$wsdl ($filename) not in cache (2)"); 00107 } 00108 $this->releaseMutex($filename); 00109 return (!is_null($s)) ? unserialize($s) : null; 00110 } else { 00111 $this->debug("Unable to obtain mutex for $filename in get"); 00112 } 00113 return null; 00114 }
nusoap_wsdlcache::nusoap_wsdlcache | ( | $ | cache_dir = '.' , |
|
$ | cache_lifetime = 0 | |||
) |
constructor
string | $cache_dir directory for cache-files | |
integer | $cache_lifetime lifetime for caching-files in seconds or 0 for unlimited public |
Definiert in Zeile 47 der Datei class.wsdlcache.php.
00047 { 00048 $this->fplock = array(); 00049 $this->cache_dir = $cache_dir != '' ? $cache_dir : '.'; 00050 $this->cache_lifetime = $cache_lifetime; 00051 }
nusoap_wsdlcache::obtainMutex | ( | $ | filename, | |
$ | mode | |||
) |
obtains the local mutex
string | $filename The Filename of the Cache to lock | |
string | $mode The open-mode ("r" or "w") or the file - affects lock-mode |
Definiert in Zeile 124 der Datei class.wsdlcache.php.
00124 { 00125 if (isset($this->fplock[md5($filename)])) { 00126 $this->debug("Lock for $filename already exists"); 00127 return false; 00128 } 00129 $this->fplock[md5($filename)] = fopen($filename.".lock", "w"); 00130 if ($mode == "r") { 00131 return flock($this->fplock[md5($filename)], LOCK_SH); 00132 } else { 00133 return flock($this->fplock[md5($filename)], LOCK_EX); 00134 } 00135 }
nusoap_wsdlcache::put | ( | $ | wsdl_instance | ) |
adds a wsdl instance to the cache
Definiert in Zeile 144 der Datei class.wsdlcache.php.
00144 { 00145 $filename = $this->createFilename($wsdl_instance->wsdl); 00146 $s = serialize($wsdl_instance); 00147 if ($this->obtainMutex($filename, "w")) { 00148 $fp = fopen($filename, "w"); 00149 if (! $fp) { 00150 $this->debug("Cannot write $wsdl_instance->wsdl ($filename) in cache"); 00151 $this->releaseMutex($filename); 00152 return false; 00153 } 00154 fputs($fp, $s); 00155 fclose($fp); 00156 $this->debug("Put $wsdl_instance->wsdl ($filename) in cache"); 00157 $this->releaseMutex($filename); 00158 return true; 00159 } else { 00160 $this->debug("Unable to obtain mutex for $filename in put"); 00161 } 00162 return false; 00163 }
nusoap_wsdlcache::releaseMutex | ( | $ | filename | ) |
releases the local mutex
string | $filename The Filename of the Cache to lock |
Definiert in Zeile 172 der Datei class.wsdlcache.php.
00172 { 00173 $ret = flock($this->fplock[md5($filename)], LOCK_UN); 00174 fclose($this->fplock[md5($filename)]); 00175 unset($this->fplock[md5($filename)]); 00176 if (! $ret) { 00177 $this->debug("Not able to release lock for $filename"); 00178 } 00179 return $ret; 00180 }
nusoap_wsdlcache::remove | ( | $ | wsdl | ) |
removes a wsdl instance from the cache
string | $wsdl The URL of the wsdl instance |
Definiert in Zeile 189 der Datei class.wsdlcache.php.
00189 { 00190 $filename = $this->createFilename($wsdl); 00191 if (!file_exists($filename)) { 00192 $this->debug("$wsdl ($filename) not in cache to be removed"); 00193 return false; 00194 } 00195 // ignore errors obtaining mutex 00196 $this->obtainMutex($filename, "w"); 00197 $ret = unlink($filename); 00198 $this->debug("Removed ($ret) $wsdl ($filename) from cache"); 00199 $this->releaseMutex($filename); 00200 return $ret; 00201 }
nusoap_wsdlcache::$cache_dir |
Definiert in Zeile 33 der Datei class.wsdlcache.php.
nusoap_wsdlcache::$cache_lifetime |
Definiert in Zeile 28 der Datei class.wsdlcache.php.
nusoap_wsdlcache::$debug_str = '' |
Definiert in Zeile 38 der Datei class.wsdlcache.php.
nusoap_wsdlcache::$fplock |
Definiert in Zeile 23 der Datei class.wsdlcache.php.
Copyright © 2003 - 2009 MyOOS [Shopsystem]. All rights reserved. MyOOS [Shopsystem] is Free Software released under the GNU/GPL License. Webmaster: info@r23.de (Impressum) |
|