| | |
| | | private $index; |
| | | private $table; |
| | | private $debug; |
| | | private $index_changed = false; |
| | | private $cache = array(); |
| | | private $cache_changes = array(); |
| | | private $cache_sums = array(); |
| | |
| | | function set($key, $data) |
| | | { |
| | | $this->cache[$key] = $data; |
| | | $this->cache_changed = true; |
| | | $this->cache_changes[$key] = true; |
| | | } |
| | | |
| | |
| | | // Remove all keys |
| | | if ($key === null) { |
| | | $this->cache = array(); |
| | | $this->cache_changed = false; |
| | | $this->cache_changes = array(); |
| | | $this->cache_sums = array(); |
| | | } |
| | |
| | | */ |
| | | function close() |
| | | { |
| | | if (!$this->cache_changed) { |
| | | return; |
| | | } |
| | | |
| | | foreach ($this->cache as $key => $data) { |
| | | // The key has been used |
| | | if ($this->cache_changes[$key]) { |
| | |
| | | } |
| | | } |
| | | |
| | | if ($this->index_changed) { |
| | | $this->write_index(); |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | if ($result) { |
| | | $this->index_changed = true; |
| | | } |
| | | |
| | | return $result; |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | if ($result) { |
| | | $this->index_changed = true; |
| | | } |
| | | |
| | | if ($index) { |
| | | if (($idx = array_search($key, $this->index)) !== false) { |
| | | unset($this->index[$idx]); |