Storage of Dependency Records

The Dependency Manager is responsible for the creation of new dependency records on the database, and for the removal of existing dependency records which are no longer required1.

Every time that a client of the Dependency Manager calculates the value of a dependent, the client is responsible for identifying the precedents used in that calculation, and for passing that dependent and its set of precedents to the Dependency Manager. The Dependency Manager uses that dependent to retrieve its existing set of stored dependencies (if any) from the database, and creates or removes dependency records in line with the new set of precedents identified by the client.

Typically, the first time that the Dependency Manager is invoked for a dependent, the Dependency Manager will create several new rows on the database to store the dependencies on the precedents identified.

However, on subsequent invocations of the Dependency Manager for the same dependent, it is very common for the Dependency Manager to find that the new set of required dependencies passed in exactly matches those already stored on the database, and so under these circumstances there are no database writes for the Dependency Manager to perform. Occasionally the Dependency Manager will find that a small number of new dependency rows are required, and/or a small number of existing dependency rows are now extraneous and must be removed; and under these circumstances the Dependency Manager performs a small number of database writes to bring the stored rows up-to-date with the required dependencies, leaving the bulk of the dependency records unchanged for the dependent.

Clients of the Dependency Manager may identify that dependency records are no longer required for a dependent, and can instruct the Dependency Manager to remove all dependency records for that dependent.

1 Each dependency record does not contain any modifiable information, and the Dependency Manager never modifies any existing dependency records - it only ever creates new records or removes existing records.