SVN
| Revision 1490,
757 bytes
checked in by anatoo, 10 months ago
(diff) |
|
0.2ブランチのリビジョン1489,1488の変更をtrunkに取り込んだ
|
| Line | |
|---|
| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * @package PEG |
|---|
| 4 | * @author anatoo<anatoo@nequal.jp> |
|---|
| 5 | * @license http://www.opensource.org/licenses/mit-license.php MIT License |
|---|
| 6 | * @version $Id: Cache.php 785 2009-05-03 09:02:28Z anatoo $ |
|---|
| 7 | */ |
|---|
| 8 | |
|---|
| 9 | class PEG_Cache |
|---|
| 10 | { |
|---|
| 11 | protected $data = array(); |
|---|
| 12 | |
|---|
| 13 | function save(PEG_IParser $parser, $start, $end, $val) |
|---|
| 14 | { |
|---|
| 15 | $this->data[$this->genkey($parser, $start)] = array($end, $val); |
|---|
| 16 | } |
|---|
| 17 | |
|---|
| 18 | protected function genkey($parser, $start) |
|---|
| 19 | { |
|---|
| 20 | return spl_object_hash($parser) . ':' . $start; |
|---|
| 21 | } |
|---|
| 22 | |
|---|
| 23 | function cache(PEG_IParser $parser, $start) |
|---|
| 24 | { |
|---|
| 25 | $key = $this->genkey($parser, $start); |
|---|
| 26 | return isset($this->data[$key]) ? array(true, $this->data[$key]) : array(false, false); |
|---|
| 27 | } |
|---|
| 28 | } |
|---|
Note: See
TracBrowser
for help on using the repository browser.