Hazelcast C++ Client
Hazelcast C++ Client Library
Loading...
Searching...
No Matches
hazelcast::client::config::near_cache_config Class Reference

Contains the configuration for a Near Cache. More...

#include <near_cache_config.h>

Public Types

enum  local_update_policy { INVALIDATE , CACHE }
 Local Update Policy enum. More...

Public Member Functions

 near_cache_config (const std::string &cache_name)
 near_cache_config (const std::string &cache_name, in_memory_format memory_format)
 near_cache_config (int32_t time_to_live_seconds, int32_t max_idle_seconds, bool invalidate_on_change, in_memory_format in_memory_format, const eviction_config &evict_config)
const std::string & get_name () const
 Gets the name of the Near Cache.
near_cache_configset_name (const std::string &name)
 Sets the name of the Near Cache.
int32_t get_time_to_live_seconds () const
 Gets the maximum number of seconds for each entry to stay in the Near Cache.
near_cache_configset_time_to_live_seconds (int32_t time_to_live_seconds)
 Sets the maximum number of seconds for each entry to stay in the Near Cache.
int32_t get_max_idle_seconds () const
 Maximum number of seconds each entry can stay in the Near Cache as untouched (not-read).
near_cache_configset_max_idle_seconds (int32_t max_idle_seconds)
 Maximum number of seconds each entry can stay in the Near Cache as untouched (not-read).
bool is_invalidate_on_change () const
 True to evict the cached entries if the entries are changed (updated or removed).
near_cache_configset_invalidate_on_change (bool invalidate_on_change)
 True to evict the cached entries if the entries are changed (updated or removed).
const in_memory_format & get_in_memory_format () const
 Gets the data type used to store entries.
virtual near_cache_configset_in_memory_format (const in_memory_format &in_memory_format)
 Sets the data type used to store entries.
bool is_cache_local_entries () const
near_cache_configset_cache_local_entries (bool cache_local_entries)
const local_update_policyget_local_update_policy () const
near_cache_configset_local_update_policy (const local_update_policy &local_update_policy)
eviction_configget_eviction_config ()
 The eviction configuration.
near_cache_configset_eviction_config (const eviction_config &eviction_config)
 Sets the eviction configuration.

Static Public Attributes

static constexpr int32_t DEFAULT_TTL_SECONDS = 0
 Default value of the time to live in seconds.
static constexpr int32_t DEFAULT_MAX_IDLE_SECONDS = 0
 Default value of the idle time for eviction in seconds.
static constexpr in_memory_format DEFAULT_MEMORY_FORMAT
 Default value for the in-memory format.

Friends

std::ostream HAZELCAST_API & operator<< (std::ostream &out, const near_cache_config &cache_config)

Detailed Description

Contains the configuration for a Near Cache.

@BinaryInterface

Definition at line 33 of file near_cache_config.h.

Member Enumeration Documentation

◆ local_update_policy

Local Update Policy enum.

Enumerator
INVALIDATE 

INVALIDATE POLICY.

CACHE 

CACHE ON UPDATE POLICY.

Definition at line 55 of file near_cache_config.h.

Constructor & Destructor Documentation

◆ near_cache_config() [1/4]

hazelcast::client::config::near_cache_config::near_cache_config ( )

Definition at line 887 of file config.cpp.

888 : name_("default")
889 , time_to_live_seconds_(DEFAULT_TTL_SECONDS)
890 , max_idle_seconds_(DEFAULT_MAX_IDLE_SECONDS)
891 , in_memory_format_(DEFAULT_MEMORY_FORMAT)
892 , local_update_policy_(INVALIDATE)
893 , invalidate_on_change_(true)
894 , cache_local_entries_(false)
895{}
static constexpr in_memory_format DEFAULT_MEMORY_FORMAT
Default value for the in-memory format.
static constexpr int32_t DEFAULT_MAX_IDLE_SECONDS
Default value of the idle time for eviction in seconds.
static constexpr int32_t DEFAULT_TTL_SECONDS
Default value of the time to live in seconds.

◆ near_cache_config() [2/4]

hazelcast::client::config::near_cache_config::near_cache_config ( const std::string & cache_name)

Definition at line 897 of file config.cpp.

898 : near_cache_config()
899{
900 name_ = cache_name;
901}

◆ near_cache_config() [3/4]

hazelcast::client::config::near_cache_config::near_cache_config ( const std::string & cache_name,
in_memory_format memory_format )

Definition at line 903 of file config.cpp.

905 : near_cache_config(cache_name)
906{
907 this->in_memory_format_ = memory_format;
908}

◆ near_cache_config() [4/4]

hazelcast::client::config::near_cache_config::near_cache_config ( int32_t time_to_live_seconds,
int32_t max_idle_seconds,
bool invalidate_on_change,
in_memory_format in_memory_format,
const eviction_config & evict_config )

Definition at line 910 of file config.cpp.

915 : near_cache_config(name_, in_memory_format)
916{
917 this->time_to_live_seconds_ = time_to_live_seconds;
918 this->max_idle_seconds_ = max_idle_seconds;
919 this->invalidate_on_change_ = invalidate_on_change;
920 this->eviction_config_ = evict_config;
921}

Member Function Documentation

◆ get_eviction_config()

eviction_config & hazelcast::client::config::near_cache_config::get_eviction_config ( )

The eviction configuration.

Returns
The eviction configuration.

Definition at line 1019 of file config.cpp.

1020{
1021 return eviction_config_;
1022}

◆ get_in_memory_format()

const in_memory_format & hazelcast::client::config::near_cache_config::get_in_memory_format ( ) const

Gets the data type used to store entries.

Possible values: BINARY (default): keys and values are stored as binary data. OBJECT: values are stored in their object forms.

Returns
The data type used to store entries.

Definition at line 978 of file config.cpp.

979{
980 return in_memory_format_;
981}

◆ get_local_update_policy()

const near_cache_config::local_update_policy & hazelcast::client::config::near_cache_config::get_local_update_policy ( ) const

Definition at line 1005 of file config.cpp.

1006{
1007 return local_update_policy_;
1008}

◆ get_max_idle_seconds()

int32_t hazelcast::client::config::near_cache_config::get_max_idle_seconds ( ) const

Maximum number of seconds each entry can stay in the Near Cache as untouched (not-read).

Entries that are not read (touched) more than max-idle-seconds value will get removed from the Near Cache.

Returns
Maximum number of seconds each entry can stay in the Near Cache as untouched (not-read).

Definition at line 951 of file config.cpp.

952{
953 return max_idle_seconds_;
954}

◆ get_name()

const std::string & hazelcast::client::config::near_cache_config::get_name ( ) const

Gets the name of the Near Cache.

Returns
The name of the Near Cache.

Definition at line 924 of file config.cpp.

925{
926 return name_;
927}

◆ get_time_to_live_seconds()

int32_t hazelcast::client::config::near_cache_config::get_time_to_live_seconds ( ) const

Gets the maximum number of seconds for each entry to stay in the Near Cache.

Entries that are older than time-to-live-seconds will get automatically evicted from the Near Cache.

Returns
The maximum number of seconds for each entry to stay in the Near Cache.

Definition at line 937 of file config.cpp.

938{
939 return time_to_live_seconds_;
940}

◆ is_cache_local_entries()

bool hazelcast::client::config::near_cache_config::is_cache_local_entries ( ) const
Deprecated
This method has no effect on client side. If true, cache local entries also. This is useful when in-memory-format for Near Cache is different than the map's one.
Returns
True if local entries are cached also.

Definition at line 992 of file config.cpp.

993{
994 return cache_local_entries_;
995}

◆ is_invalidate_on_change()

bool hazelcast::client::config::near_cache_config::is_invalidate_on_change ( ) const

True to evict the cached entries if the entries are changed (updated or removed).

When true, the member listens for cluster-wide changes on the entries and invalidates them on change. Changes done on the local member always invalidate the cache.

Returns
This Near Cache config instance.

Definition at line 965 of file config.cpp.

966{
967 return invalidate_on_change_;
968}

◆ set_cache_local_entries()

near_cache_config & hazelcast::client::config::near_cache_config::set_cache_local_entries ( bool cache_local_entries)
Deprecated
This method has no effect on client side. True to cache local entries also. This is useful when in-memory-format for Near Cache is different than the map's one.
Parameters
cacheLocalEntriesTrue to cache local entries also.
Returns
This Near Cache config instance.

Definition at line 998 of file config.cpp.

999{
1000 this->cache_local_entries_ = cache_local_entries;
1001 return *this;
1002}

◆ set_eviction_config()

near_cache_config & hazelcast::client::config::near_cache_config::set_eviction_config ( const eviction_config & eviction_config)

Sets the eviction configuration.

Parameters
evictionConfigThe eviction configuration.
Returns
This Near Cache config instance.

Definition at line 1025 of file config.cpp.

1026{
1027 this->eviction_config_ = eviction_config;
1028 return *this;
1029}

◆ set_in_memory_format()

near_cache_config & hazelcast::client::config::near_cache_config::set_in_memory_format ( const in_memory_format & in_memory_format)
virtual

Sets the data type used to store entries.

Possible values: BINARY (default): keys and values are stored as binary data. OBJECT: values are stored in their object forms.

Parameters
inMemoryFormatThe data type used to store entries.
Returns
This Near Cache config instance.

Definition at line 984 of file config.cpp.

986{
987 this->in_memory_format_ = in_memory_format;
988 return *this;
989}

◆ set_invalidate_on_change()

near_cache_config & hazelcast::client::config::near_cache_config::set_invalidate_on_change ( bool invalidate_on_change)

True to evict the cached entries if the entries are changed (updated or removed).

If set to true, the member will listen for cluster-wide changes on the entries and invalidate them on change. Changes done on the local member always invalidate the cache.

Parameters
invalidateOnChangeTrue to evict the cached entries if the entries are changed (updated or removed), false otherwise.
Returns
This Near Cache config instance.

Definition at line 971 of file config.cpp.

972{
973 this->invalidate_on_change_ = invalidate_on_change;
974 return *this;
975}

◆ set_local_update_policy()

near_cache_config & hazelcast::client::config::near_cache_config::set_local_update_policy ( const local_update_policy & local_update_policy)

Definition at line 1011 of file config.cpp.

1013{
1014 this->local_update_policy_ = local_update_policy;
1015 return *this;
1016}

◆ set_max_idle_seconds()

near_cache_config & hazelcast::client::config::near_cache_config::set_max_idle_seconds ( int32_t max_idle_seconds)

Maximum number of seconds each entry can stay in the Near Cache as untouched (not-read).

Entries that are not read (touched) more than max-idle-seconds value will get removed from the Near Cache. Any integer between 0 and Integer.MAX_VALUE. 0 means INT32_MAX. Default is 0.

Parameters
maxIdleSecondsMaximum number of seconds each entry can stay in the Near Cache as untouched (not-read).
Returns
This Near Cache config instance.

Definition at line 957 of file config.cpp.

958{
959 this->max_idle_seconds_ = util::Preconditions::check_not_negative(
960 max_idle_seconds, "Max-Idle seconds cannot be negative!");
961 return *this;
962}

◆ set_name()

near_cache_config & hazelcast::client::config::near_cache_config::set_name ( const std::string & name)

Sets the name of the Near Cache.

Parameters
nameThe name of the Near Cache.
Returns
This Near Cache config instance.

Definition at line 930 of file config.cpp.

931{
932 this->name_ = name;
933 return *this;
934}

◆ set_time_to_live_seconds()

near_cache_config & hazelcast::client::config::near_cache_config::set_time_to_live_seconds ( int32_t time_to_live_seconds)

Sets the maximum number of seconds for each entry to stay in the Near Cache.

Entries that are older than time-to-live-seconds will get automatically evicted from the Near Cache. Any integer between 0 and INT32_MAX. 0 means infinite. Default is 0.

Parameters
timeToLiveSecondsThe maximum number of seconds for each entry to stay in the Near Cache.
Returns
This Near Cache config instance.

Definition at line 943 of file config.cpp.

944{
945 this->time_to_live_seconds_ = util::Preconditions::check_not_negative(
946 time_to_live_seconds, "TTL seconds cannot be negative!");
947 return *this;
948}

◆ operator<<

std::ostream HAZELCAST_API & operator<< ( std::ostream & out,
const near_cache_config & cache_config )
friend

Definition at line 1031 of file config.cpp.

1033{
1034 out << "NearCacheConfig{"
1035 << "timeToLiveSeconds=" << config.time_to_live_seconds_
1036 << ", maxIdleSeconds=" << config.max_idle_seconds_
1037 << ", invalidateOnChange=" << config.invalidate_on_change_
1038 << ", inMemoryFormat=" << config.in_memory_format_
1039 << ", cacheLocalEntries=" << config.cache_local_entries_
1040 << ", localUpdatePolicy=" << config.local_update_policy_
1041 << config.eviction_config_;
1042 out << '}';
1043
1044 return out;
1045}

Member Data Documentation

◆ DEFAULT_MAX_IDLE_SECONDS

int32_t hazelcast::client::config::near_cache_config::DEFAULT_MAX_IDLE_SECONDS = 0
staticconstexpr

Default value of the idle time for eviction in seconds.

Definition at line 44 of file near_cache_config.h.

◆ DEFAULT_MEMORY_FORMAT

in_memory_format hazelcast::client::config::near_cache_config::DEFAULT_MEMORY_FORMAT
staticconstexpr
Initial value:
=
in_memory_format::BINARY

Default value for the in-memory format.

Definition at line 49 of file near_cache_config.h.

◆ DEFAULT_TTL_SECONDS

int32_t hazelcast::client::config::near_cache_config::DEFAULT_TTL_SECONDS = 0
staticconstexpr

Default value of the time to live in seconds.

Definition at line 39 of file near_cache_config.h.


The documentation for this class was generated from the following files: