channelCache.getBoolean¶
Signature: channelCache.getBoolean(key, defaultValue*)
Returns: Boolean booleanValue - the value associated with the Boolean-typed key
Get the Boolean-typed value associated with the key.
Note
A ClassCastException will be thrown if the cache is not of type Boolean.
Note
A NullPointerException will be thrown if the cache does not exist and the defaultValue is omitted.
Parameters¶
| Type | Name | Description | Default |
|---|---|---|---|
| String | key | a unique string used to identify the cached value | |
| Boolean | defaultValue* | (optional) the value to return if no value is associated with the key |
exception is thrown if the key does not exist, and it's impossible to not have a value |
Example¶
// Read a stored Boolean-typed channel-cache entry. The default value is OPTIONAL:
// (1) With a default -- always safe; the default is returned when the key is unset:
var betaMode = channelCache.getBoolean("betaMode", false); // stored value, or false if unset
// (2) Without a default -- returns the stored Boolean directly, but a missing key throws
// (the null is unboxed to a primitive), so omit the default only when the key is set:
if (channelCache.checkValueExists("featureEnabled")) {
var featureEnabled = channelCache.getBoolean("featureEnabled"); // the stored Boolean
}