Event caches hold a number of previous events for the input stream or streams to a derived stream. They are organized into buckets, based on values of the fields in the records and are often used when vectors or dictionaries are not quite the right data structure.
eventCache(input_stream) e0;This event cache holds all the events for an input stream "input_stream". The default key structure of the input stream defines the bucket policy. That is, the buckets in this stream correspond to the keys of the input stream.
<input_stream ESP_OPS="i" k="1" d="10"/> <input_stream ESP_OPS="u" k="1" d="11"/> <input_stream ESP_OPS="i" k="2" d="21"/>After these events have flowed in, there will be two buckets. The first bucket will contain the first two events, because these have the same key; the second bucket will contain the last event.
<input_stream ESP_OPS="u" k="1" d="12"/>For instance, if the above event appears in this stream, then the expression sum(e0.d) returns 10+11+12=33. You can use any of the accepted aggregation functions, including avg, count, max, and min.