64 $this->_stream = $stream;
67 if (function_exists(
'get_magic_quotes_runtime') && @get_magic_quotes_runtime() == 1) {
68 $this->_quotes =
true;
84 public function setString($nsKey, $itemKey, $string, $mode)
88 case self::MODE_WRITE:
89 $fp = $this->
_getHandle($nsKey, $itemKey, self::POSITION_START);
91 case self::MODE_APPEND:
92 $fp = $this->
_getHandle($nsKey, $itemKey, self::POSITION_END);
96 'Invalid mode ['.$mode.
'] used to set nsKey='.
97 $nsKey.
', itemKey='.$itemKey
101 fwrite($fp, $string);
121 case self::MODE_WRITE:
122 $fp = $this->
_getHandle($nsKey, $itemKey, self::POSITION_START);
124 case self::MODE_APPEND:
125 $fp = $this->
_getHandle($nsKey, $itemKey, self::POSITION_END);
129 'Invalid mode ['.$mode.
'] used to set nsKey='.
130 $nsKey.
', itemKey='.$itemKey
134 while (
false !== $bytes = $os->
read(8192)) {
154 $is->setKeyCache($this);
155 $is->setNsKey($nsKey);
156 $is->setItemKey($itemKey);
157 if (isset($writeThrough)) {
158 $is->setWriteThroughStream($writeThrough);
177 if ($this->
hasKey($nsKey, $itemKey)) {
178 $fp = $this->
_getHandle($nsKey, $itemKey, self::POSITION_START);
179 if ($this->_quotes) {
180 ini_set(
'magic_quotes_runtime', 0);
183 while (!feof($fp) &&
false !== $bytes = fread($fp, 8192)) {
186 if ($this->_quotes) {
187 ini_set(
'magic_quotes_runtime', 1);
204 if ($this->
hasKey($nsKey, $itemKey)) {
205 $fp = $this->
_getHandle($nsKey, $itemKey, self::POSITION_START);
206 if ($this->_quotes) {
207 ini_set(
'magic_quotes_runtime', 0);
209 while (!feof($fp) &&
false !== $bytes = fread($fp, 8192)) {
212 if ($this->_quotes) {
213 ini_set(
'magic_quotes_runtime', 1);
229 return is_file($this->_path.
'/'.$nsKey.
'/'.$itemKey);
240 if ($this->
hasKey($nsKey, $itemKey)) {
242 unlink($this->_path.
'/'.$nsKey.
'/'.$itemKey);
253 if (array_key_exists($nsKey, $this->_keys)) {
254 foreach ($this->_keys[$nsKey] as $itemKey => $null) {
257 if (is_dir($this->_path.
'/'.$nsKey)) {
258 rmdir($this->_path.
'/'.$nsKey);
260 unset($this->_keys[$nsKey]);
271 $cacheDir = $this->_path.
'/'.$nsKey;
272 if (!is_dir($cacheDir)) {
273 if (!mkdir($cacheDir)) {
276 $this->_keys[$nsKey] = array();
291 if (!isset($this->_keys[$nsKey][$itemKey])) {
292 $openMode = $this->
hasKey($nsKey, $itemKey)
296 $fp = fopen($this->_path.
'/'.$nsKey.
'/'.$itemKey, $openMode);
297 $this->_keys[$nsKey][$itemKey] = $fp;
299 if (self::POSITION_START == $position) {
300 fseek($this->_keys[$nsKey][$itemKey], 0, SEEK_SET);
301 }
elseif (self::POSITION_END == $position) {
302 fseek($this->_keys[$nsKey][$itemKey], 0, SEEK_END);
305 return $this->_keys[$nsKey][$itemKey];
310 $fp = $this->
_getHandle($nsKey, $itemKey, self::POSITION_CURRENT);
312 $this->_keys[$nsKey][$itemKey] = null;
320 foreach ($this->_keys as $nsKey => $null) {