ILIAS  Release_4_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
wsdlcache Class Reference

caches instances of the wsdl class More...

+ Inheritance diagram for wsdlcache:
+ Collaboration diagram for wsdlcache:

Public Member Functions

 wsdlcache ($cache_dir='.', $cache_lifetime=0)
 constructor
 createFilename ($wsdl)
 creates the filename used to cache a wsdl instance
 debug ($string)
 adds debug data to the class level debug string
 get ($wsdl)
 gets a wsdl instance from the cache
 obtainMutex ($filename, $mode)
 obtains the local mutex
 put ($wsdl_instance)
 adds a wsdl instance to the cache
 releaseMutex ($filename)
 releases the local mutex
 remove ($wsdl)
 removes a wsdl instance from the cache
- Public Member Functions inherited from nusoap_wsdlcache
 nusoap_wsdlcache ($cache_dir='.', $cache_lifetime=0)
 constructor

Data Fields

 $fplock
 $cache_lifetime
 $cache_dir
 $debug_str = ''
- Data Fields inherited from nusoap_wsdlcache
 $fplock
 $cache_lifetime
 $cache_dir
 $debug_str = ''

Detailed Description

caches instances of the wsdl class

For backward compatibility.

Author
Scott Nichol snich.nosp@m.ol@c.nosp@m.omput.nosp@m.er.o.nosp@m.rg
Ingo Fischer ingo@.nosp@m.apol.nosp@m.lon.d.nosp@m.e
Version
Id:
class.wsdlcache.php 14918 2007-10-07 17:02:40Z rkuester

public

Definition at line 13 of file class.wsdlcache.php.

Member Function Documentation

wsdlcache::createFilename (   $wsdl)

creates the filename used to cache a wsdl instance

Parameters
string$wsdlThe URL of the wsdl instance
Returns
string The filename used to cache the instance private

Reimplemented from nusoap_wsdlcache.

Definition at line 55 of file class.wsdlcache.php.

References $wsdl.

Referenced by get(), put(), and remove().

{
return $this->cache_dir.'/wsdlcache-' . md5($wsdl);
}

+ Here is the caller graph for this function:

wsdlcache::debug (   $string)

adds debug data to the class level debug string

Parameters
string$stringdebug data private

Reimplemented from nusoap_wsdlcache.

Definition at line 65 of file class.wsdlcache.php.

Referenced by get(), obtainMutex(), put(), releaseMutex(), and remove().

{
$this->debug_str .= get_class($this).": $string\n";
}

+ Here is the caller graph for this function:

wsdlcache::get (   $wsdl)

gets a wsdl instance from the cache

Parameters
string$wsdlThe URL of the wsdl instance
Returns
object wsdl The cached wsdl instance, null if the instance is not in the cache public

Reimplemented from nusoap_wsdlcache.

Definition at line 76 of file class.wsdlcache.php.

References $filename, $wsdl, createFilename(), debug(), obtainMutex(), and releaseMutex().

{
if ($this->obtainMutex($filename, "r")) {
// check for expired WSDL that must be removed from the cache
if ($this->cache_lifetime > 0) {
if (file_exists($filename) && (time() - filemtime($filename) > $this->cache_lifetime)) {
unlink($filename);
$this->debug("Expired $wsdl ($filename) from cache");
return null;
}
}
// see what there is to return
$fp = @fopen($filename, "r");
if ($fp) {
$s = implode("", @file($filename));
fclose($fp);
$this->debug("Got $wsdl ($filename) from cache");
} else {
$s = null;
$this->debug("$wsdl ($filename) not in cache");
}
return (!is_null($s)) ? unserialize($s) : null;
} else {
$this->debug("Unable to obtain mutex for $filename in get");
}
return null;
}

+ Here is the call graph for this function:

wsdlcache::obtainMutex (   $filename,
  $mode 
)

obtains the local mutex

Parameters
string$filenameThe Filename of the Cache to lock
string$modeThe open-mode ("r" or "w") or the file - affects lock-mode
Returns
boolean Lock successfully obtained ?! private

Reimplemented from nusoap_wsdlcache.

Definition at line 114 of file class.wsdlcache.php.

References $filename, and debug().

Referenced by get(), put(), and remove().

{
if (isset($this->fplock[md5($filename)])) {
$this->debug("Lock for $filename already exists");
return false;
}
$this->fplock[md5($filename)] = fopen($filename.".lock", "w");
if ($mode == "r") {
return flock($this->fplock[md5($filename)], LOCK_SH);
} else {
return flock($this->fplock[md5($filename)], LOCK_EX);
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

wsdlcache::put (   $wsdl_instance)

adds a wsdl instance to the cache

Parameters
objectwsdl $wsdl_instance The wsdl instance to add
Returns
boolean WSDL successfully cached public

Reimplemented from nusoap_wsdlcache.

Definition at line 134 of file class.wsdlcache.php.

References $filename, createFilename(), debug(), obtainMutex(), and releaseMutex().

{
$filename = $this->createFilename($wsdl_instance->wsdl);
$s = serialize($wsdl_instance);
if ($this->obtainMutex($filename, "w")) {
$fp = fopen($filename, "w");
fputs($fp, $s);
fclose($fp);
$this->debug("Put $wsdl_instance->wsdl ($filename) in cache");
return true;
} else {
$this->debug("Unable to obtain mutex for $filename in put");
}
return false;
}

+ Here is the call graph for this function:

wsdlcache::releaseMutex (   $filename)

releases the local mutex

Parameters
string$filenameThe Filename of the Cache to lock
Returns
boolean Lock successfully released private

Reimplemented from nusoap_wsdlcache.

Definition at line 157 of file class.wsdlcache.php.

References $filename, $ret, and debug().

Referenced by get(), put(), and remove().

{
$ret = flock($this->fplock[md5($filename)], LOCK_UN);
fclose($this->fplock[md5($filename)]);
unset($this->fplock[md5($filename)]);
if (! $ret) {
$this->debug("Not able to release lock for $filename");
}
return $ret;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

wsdlcache::remove (   $wsdl)

removes a wsdl instance from the cache

Parameters
string$wsdlThe URL of the wsdl instance
Returns
boolean Whether there was an instance to remove public

Reimplemented from nusoap_wsdlcache.

Definition at line 174 of file class.wsdlcache.php.

References $filename, $ret, $wsdl, createFilename(), debug(), obtainMutex(), and releaseMutex().

{
// ignore errors obtaining mutex
$this->obtainMutex($filename, "w");
$ret = unlink($filename);
$this->debug("Removed ($ret) $wsdl ($filename) from cache");
return $ret;
}

+ Here is the call graph for this function:

wsdlcache::wsdlcache (   $cache_dir = '.',
  $cache_lifetime = 0 
)

constructor

Parameters
string$cache_dirdirectory for cache-files
integer$cache_lifetimelifetime for caching-files in seconds or 0 for unlimited public

Definition at line 42 of file class.wsdlcache.php.

References $cache_dir, and $cache_lifetime.

{
$this->fplock = array();
$this->cache_dir = $cache_dir != '' ? $cache_dir : '.';
$this->cache_lifetime = $cache_lifetime;
}

Field Documentation

wsdlcache::$cache_dir

Definition at line 28 of file class.wsdlcache.php.

Referenced by wsdlcache().

wsdlcache::$cache_lifetime

Definition at line 23 of file class.wsdlcache.php.

Referenced by wsdlcache().

wsdlcache::$debug_str = ''

Definition at line 33 of file class.wsdlcache.php.

wsdlcache::$fplock

Definition at line 18 of file class.wsdlcache.php.


The documentation for this class was generated from the following file: