Put#

Save data to the backend; raw pointers are not supported for Put.

template<typename T>
ObjectRef<T> YR::Put(const T &val)#

Put an object to datasystem.

auto objRef = YR::Put(100);
auto value = *(YR::Get(objRef));
assert(value == 100);  // should be 100

Template Parameters:

T – the template.

Parameters:

val – the object.

Throws:

Exception – if Yuanrong is not initialized.

Returns:

ObjectRef<T> the object ref of the object.

template<typename T>
ObjectRef<T> YR::Put(const T &val, const CreateParam &createParam)#

Put an object to datasystem.

YR::CreateParam param;
param.writeMode = YR::WriteMode::NONE_L2_CACHE_EVICT;
param.consistencyType = YR::ConsistencyType::PRAM;
param.cacheType = YR::CacheType::DISK;
auto objRef = YR::Put(100, param);
auto value = *(YR::Get(objRef));
assert(value == 100);  // should be 100

Template Parameters:

T – the template.

Parameters:
  • val – the object.

  • createParam – the create param, Refer to the parameter structure supplement below for details.

Throws:

Exception – if Yuanrong is not initialized.

Returns:

ObjectRef<T> the object ref of the object.

The parameter structure is supplemented with the following explanation:

struct CreateParam#

Configure attributes for the object, such as whether reliability is needed.

Public Members

WriteMode writeMode = WriteMode::NONE_L2_CACHE#

write mode

Set the reliability of the data. When the server configuration supports a secondary cache to ensure reliability, such as the Redis service, this configuration can be used to guarantee data reliability. Defaults to YR::WriteMode::NONE_L2_CACHE .

ConsistencyType consistencyType = ConsistencyType::PRAM#

consistency type

Data consistency configuration. In a distributed scenario, different levels of consistency semantics can be configured. The optional parameters are:

CacheType cacheType = CacheType::MEMORY#

cacheType

Identifies whether the allocated medium is memory or disk. The optional parameters are:

enum class YR::ConsistencyType : int#

Data Consistency Configuration.

In a distributed scenario, different levels of consistency semantics can be configured.

Values:

enumerator PRAM#

Asynchronous.

enumerator CAUSAL#

Causal Consistency.