Replace and Merge
rvcache can store message data in two ways. For each subject, it can either replace all previously stored data with the contents of each new message, or it can merge information from the fields of the message into the stored data, overwriting only those fields specified in the new message.
Select one of these two storage methods each time you add a subject.
Furthermore, rvcache can merge data in either of two ways. The command line parameter -merge selects either shallow merge or deep merge as the behavior of the cache, consistent for all merged subjects. Consider a new message that contains nested messages as field values.
| • | Shallow merge replaces the old field value with the new nested message as an indivisible unit, without special treatment for the individual fields of the nested message. That is, merging occurs at only one level of nesting; level-one fields replace level-one fields. |
| • | Deep merge inspects the fields of nested messages, and recursively merges the fields of a new nested message into fields of a stored nested message. Merging continues recursively to any depth of nesting. |
rvcache Replace and Merge presents an example, contrasting the different behavior of replacement, shallow merge and deep merge.
|
Stored Message |
Replace |
Shallow Merge |
Deep Merge |
{
|
{
The new message (in this column) replaces the stored message as an indivisible unit. After replacement, the stored message is an identical copy of the new message. |
{
Fields of the stored message remain in place, except where superseded by the fields of the new message. Existing The new The new value of |
{
Existing The new The new value of |
Data stored in rvcache never expires. It remains in the cache until superseded or augmented by data from a new message on the same subject.