KV().MWriteTx

KV().MWriteTx#

template<typename T>
static inline void YR::KVManager::MWriteTx(const std::vector<std::string> &keys, const std::vector<T> &vals, ExistenceOpt existence)#

Sets multiple key-value pairs.

Values will be serialized by msgpack. All operations on key-value pairs must either succeed completely or fail completely.

int count = 100;
Counter c("Counter1-", count);
std::vector<std::string> keys = {c.name};
std::vector<Counter> vals = {c};
try {
    YR::KV().MWriteTx<Counter>(keys, vals, YR::ExistenceOpt::NX);
} catch (YR::Exception &e) {
    // handle exception...
}

Note

Maximum call frequency specification is 250 calls per second.

Template Parameters:

T – The type of the object.

Parameters:
  • keys[in] An array of keys used to identify stored data. Maximum array length is 8. Each element must match the regular expression: ^[a-zA-Z0-9\~\.\-\/_!@#%\^\&\*\(\)\+\=\:;]*$.

  • vals[in] An array of data to be stored in the data system. The positions of data in this array must correspond to the positions of keys in the keys array. The length of this array must match the keys array.

  • existence[in] Must be set to YR::ExistenceOpt::NX.

Throws:

Exception

  • 1001: Parameter error. Detailed error information will be provided.

  • 4206: Key already exists. If existence is set to YR::ExistenceOpt::NX and one or more keys in the list have been previously set or written.

  • Other exceptions may be thrown due to errors during the Set operation, with detailed descriptions provided in the error message.

template<typename T>
static inline void YR::KVManager::MWriteTx(const std::vector<std::string> &keys, const std::vector<T> &vals, const MSetParam &mSetParam)#

Sets multiple key-value pairs.

Values will be serialized by msgpack. All operations on key-value pairs must either succeed completely or fail completely.

int count = 100;
Counter c("Counter1-", count);
std::vector<std::string> keys = {c.name};
std::vector<Counter> vals = {c};
YR::MSetParam param;
param.ttlSecond = 0;
param.writeMode = YR::WriteMode::NONE_L2_CACHE_EVICT;
param.existence = YR::ExistenceOpt::NONE;
param.cacheType = YR::CacheType::MEMORY;
try {
    YR::KV().MWriteTx<Counter>(keys, vals, param);
} catch (YR::Exception &e) {
    // handle exception...
}

Note

Maximum call frequency specification is 250 calls per second.

Template Parameters:

T – The type of the object.

Parameters:
  • keys[in] An array of keys used to identify stored data. Maximum array length is 8. Each element must match the regular expression: ^[a-zA-Z0-9.-\/_!#%\^&*()+=\:;]*$.

  • vals[in] An array of data to be stored in the data system. The positions of data in this array must correspond to the positions of keys in the keys array. The length of this array must match the keys array.

  • mSetParam[in] Configures attributes such as reliability for the object.

Throws:

Exception

  • 1001: Parameter error. Detailed error information will be provided.

  • 4206: Key already exists. If existence is set to YR::ExistenceOpt::NX and one or more keys in the list have been previously set or written.

  • Other exceptions may be thrown due to errors during the Set operation, with detailed descriptions provided in the error message.