public class CacheableOptional<T extends Serializable> extends Object implements Cacheable
Cache
the absence of a value.
Unfortunately, it's not possible to store a null
value in a clustered cache because of the underlying hazelcast
technology used for clustering. The obvious candidate would therefore be to store an Optional
object in the
cache instead - unfortunately an Optional is not serializable. This class therefore performs this functionality - an
optional value that is cacheable.Modifier and Type | Method and Description |
---|---|
boolean |
equals(Object o) |
static <T extends Serializable> |
from(Optional<T> value) |
T |
get() |
int |
getCachedSize()
Returns the approximate size of the Object in bytes.
|
int |
hashCode() |
boolean |
isAbsent() |
boolean |
isPresent() |
static <T extends Serializable> |
of(T value) |
Optional<T> |
toOptional() |
public static <T extends Serializable> CacheableOptional<T> of(T value)
public static <T extends Serializable> CacheableOptional<T> from(Optional<T> value)
public T get()
public boolean isPresent()
public boolean isAbsent()
public int getCachedSize() throws CannotCalculateSizeException
Cacheable
getCachedSize
in interface Cacheable
CannotCalculateSizeException
Copyright © 2003–2019 Ignite Realtime. All rights reserved.