74 foreach( array_keys( $this->cache, $offset ) as $k ) { unset($this->cache[$k]); }
75 $this->cache = array_values( $this->cache );
76 array_push( $this->cache, $offset );
77 while( count( $this->cache ) > $this->numCache ) {
78 $k = array_shift( $this->cache );
79 unset( $this->records[$k] );
82 if( !isset( $this->records[ $offset ] ) ) {
83 if( !isset( $this->recordOffsets[$offset] ) ) {
84 for( $i = $offset - 1 ; $i > 0 ; $i-- ) {
85 if( isset( $this->recordOffsets[$i] ) )
break;
87 fseek( $this->input, $this->recordOffsets[$i], SEEK_SET );
88 while( $i < $offset ) {
91 $this->recordOffsets[ $i ] = ftell( $this->input );
94 fseek( $this->input, $this->recordOffsets[$offset], SEEK_SET );
96 $this->records[ $offset ] =
new $this->recordClass();
97 $this->records[ $offset ]->loadFromBinaryStream( $this->input );
98 if(feof($this->input)) {
99 $this->numRecords = $offset+1;
101 $this->recordOffsets[$offset+1] = ftell( $this->input );
104 return $this->records[ $offset ];