Changeset 20334 for events/phpframework/sabel/trunk/lib/UserCache.php
- Timestamp:
- 10/01/08 04:26:27 (3 months ago)
- Files:
-
- 1 modified
-
events/phpframework/sabel/trunk/lib/UserCache.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
events/phpframework/sabel/trunk/lib/UserCache.php
r20329 r20334 29 29 { 30 30 $path = $this->getPath($userId); 31 if (is_file($path)) { 32 include ($path); 33 if ($this->check($data)) { 34 return $data; 35 } else { 36 unlink($path); 37 return false; 38 } 39 } else { 40 return false; 41 } 31 return (is_file($path)) ? $this->_read($path) : false; 42 32 } 43 33 44 34 public function lock($userId, $mode = "ab+") 45 35 { 46 $i = 0;47 36 $path = $this->getPath($userId); 37 $fp = fopen($path, $mode); 38 $data = $this->_read($path); 48 39 49 while (++$i < 5) { 50 $fp = fopen($path, $mode); 51 if (flock($fp, LOCK_EX)) { 52 ftruncate($fp, 0); 53 return $fp; 54 } else { 55 usleep(mt_rand(50000, 500000)); 56 } 40 flock($fp, LOCK_EX); 41 ftruncate($fp, 0); 42 43 return array($fp, $data); 44 } 45 46 protected function _read($path) 47 { 48 include ($path); 49 if (isset($data) && $this->check($data)) { 50 return $data; 51 } else { 52 return false; 57 53 } 58 59 return false;60 54 } 61 55
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)