Channel Cache Object¶
Channel cache is a simple key-value pair database associated with the channel. It can be used to store configuration parameters that change or modify the behavior of the channel. Cache values are persisted and can be referenced across messages. The following Channel Cache object functions are available:
| Function | Description |
|---|---|
| Check Value Exists | Check for the existence of a value associated with the key. Returns true if a value is found, false otherwise. |
| Get Boolean | Get the Boolean-typed value associated with the key. A ClassCastException is thrown if the cached value is not a Boolean, and a NullPointerException is thrown when no defaultValue is supplied and the key is not present. |
| Get Date | Get the Date-typed value associated with the key. A ClassCastException is thrown if the cached value is not a Date. |
| Get Number | Get the Number-typed value associated with the key. A ClassCastException is thrown if the cached value is not a Number, and a NullPointerException is thrown when no defaultValue is supplied and the key is not present. |
| Get Value | Get the value associated with the key. Accepts an optional defaultValue returned when the key is not present (defaults to null). |
| Remove Value | Remove the channel cache entry that matches the key. |
| Set Value | Set the value associated with the key. Returns the previous value associated with the key. |
Note
The channel cache is not thread-safe and is intended for slowly-changing configuration values. If a value is read or written from concurrent message processing, use the Shared Cache or an external database instead to ensure data consistency and avoid performance issues.