\seekquarry\yioop\libraryPersistentStructure

A PersistentStructure is a data structure which every so many operations will be saved to secondary storage (such as disk).

An operation occurs whenever the PersistentStructure's checkSave method is called. A PersistentStructure also supports the ability to be load (read in from) secondary storage.

Summary

Methods
Properties
Constants
__construct()
load()
save()
checkSave()
$filename
$unsaved_operations
$save_frequency
DEFAULT_SAVE_FREQUENCY
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

DEFAULT_SAVE_FREQUENCY

DEFAULT_SAVE_FREQUENCY

If not specified in the constructor, this will be the number of operations between saves

Properties

$filename

$filename : string

Name of the file in which to store the PersistentStructure

Type

string

$unsaved_operations

$unsaved_operations : integer

Number of operations since the last save

Type

integer

$save_frequency

$save_frequency : integer

Number of operation between saves. If == -1 never save using checkSave

Type

integer

Methods

__construct()

__construct(string  $fname, integer  $save_frequency = self::DEFAULT_SAVE_FREQUENCY) 

Sets up the file name and save frequency for the PersistentStructure, initializes the oepration count

Parameters

string $fname

the name of the file to store the PersistentStructure in

integer $save_frequency

the number of operation before a save If <= 0 never check save

load()

load(string  $fname) : object

Load a PersistentStructure from a file

Parameters

string $fname

the name of the file to load the PersistentStructure from

Returns

object —

the PersistentStructure loaded

save()

save() 

Save the PersistentStructure to its filename This method is generic but super memory inefficient, so reimplement for subclasses is needed

checkSave()

checkSave() 

Add one to the unsaved_operations count. If this goes above the save_frquency then save the PersistentStructure to secondary storage