KV().MSetTx#

static inline void YR::KVManager::MSetTx(const std::vector<std::string> &keys, const std::vector<char*> &vals, const std::vector<size_t> &lens, ExistenceOpt existence)#

A transactional interface for setting multiple binary data entries in a batch.

This function provides a Redis-like MSET interface for storing multiple binary data entries in a single transaction. It allows you to store binary data into the system using keys, ensuring that all operations are atomic.

Note

Maximum call frequency: 250 times per second.

Parameters:
  • keys – A list of keys used to identify the data entries. These keys are used to query the data later. The list cannot be empty, and its maximum length is 8.

  • vals – A list of binary data to be stored. Each data entry corresponds to a key in the keys list. The length of this list must match the length of keys.

  • lens – A list of lengths corresponding to each binary data entry in vals. Each length must match the corresponding data entry in vals. The length of this list must match the length of keys.

  • existence – The existence option for the operation. Must be set to YR::ExistenceOpt::NX (not supported, optional).

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.

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

A transactional interface for setting multiple key-value pairs in a batch.

This function provides a Redis-like MSET interface for storing multiple key-value pairs in a single transaction. It allows you to store binary data into the system using keys, ensuring that all operations are atomic.

int main() {
    YR::Config conf;
    conf.mode = Config::Mode::CLUSTER_MODE;
    YR::Init(conf);
    std::vector<std::string> keys = { "key1", "key2" };
    std::vector<std::string> vals = { "val1", "val2" };
    try {
        YR::KV().MSetTx(keys, vals, YR::ExistenceOpt::NX);
        std::cout << "Data stored successfully." << std::endl;
    } catch (const YR::Exception& e) {
        std::cerr << "Error: " << e.what() << std::endl;
    }
    return 0;
}

Note

Maximum call frequency: 250 times per second.

Parameters:
  • keys – A list of keys used to identify the data entries. These keys are used to query the data later. The list cannot be empty, and its maximum length is 8.

  • vals – A list of binary data to be stored. Each data entry corresponds to a key in the keys list. The length of this list must match the length of keys.

  • existence – The existence option for the operation. 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.

static inline void YR::KVManager::MSetTx(const std::vector<std::string> &keys, const std::vector<char*> &vals, const std::vector<size_t> &lens, const MSetParam &mSetParam)#

A transactional interface for setting multiple key-value pairs with binary data in a batch.

This function provides a Redis-like MSET interface for storing multiple key-value pairs in a single transaction. It allows you to store binary data into the system using keys, ensuring that all operations are atomic. The function also allows configuration of properties such as reliability through the MSetParam parameter.

Note

Maximum call frequency: 250 times per second.

Parameters:
  • keys – A list of keys used to identify the data entries. These keys are used to query the data later. The list cannot be empty, and its maximum length is 8.

  • vals – A list of binary data to be stored. Each data entry corresponds to a key in the keys list. The length of this list must match the length of keys.

  • lens – A list of lengths corresponding to each binary data entry in vals. Each length must match the corresponding data entry in vals. The length of this list must match the length of keys. The user must ensure that the len values are correct.

  • mSetParam – Configuration parameters for the operation, such as reliability settings.

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.

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

A transactional interface for setting multiple key-value pairs with binary data in a batch.

This function provides a Redis-like MSET interface for storing multiple key-value pairs in a single transaction. It allows you to store binary data into the system using keys, ensuring that all operations are atomic. The function also allows configuration of properties such as reliability through the MSetParam parameter.

int main() {
    YR::Config conf;
    conf.mode = Config::Mode::CLUSTER_MODE;
    YR::Init(conf);
    std::vector<std::string> keys = { "key1", "key2" };
    std::vector<std::string> vals = { "val1", "val2" };
    YR::MSetParam param;
    param.writeMode = YR::WriteMode::NONE_L2_CACHE_EVICT;
    param.ttlSecond = 10;
    param.cacheType = YR::CacheType::MEMORY;
    try {
        YR::KV().MSetTx(keys, vals, param);
        std::cout << "Data stored successfully." << std::endl;
    } catch (const YR::Exception& e) {
        std::cerr << "Error: " << e.what() << std::endl;
    }
    return 0;
}

Note

Maximum call frequency: 250 times per second.

Parameters:
  • keys – A list of keys used to identify the data entries. These keys are used to query the data later. The list cannot be empty, and its maximum length is 8.

  • vals – A list of binary data to be stored. Each data entry corresponds to a key in the keys list. The length of this list must match the length of keys.

  • mSetParam – Configuration parameters for the operation, such as reliability settings.

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.

The parameter structure is supplemented with the following explanation:

struct MSetParam#

Configures attributes for multiple objects, such as reliability.

Public Members

WriteMode writeMode = WriteMode::NONE_L2_CACHE#

Write mode.

Sets the reliability of data. When the server configuration supports a secondary cache (e.g., Redis), this setting ensures data reliability. Default value: YR::WriteMode::NONE_L2_CACHE

uint32_t ttlSecond = 0#

Time-to-Live (TTL) in seconds.

Specifies the duration for which the data will be retained before being deleted. Default value: 0, meaning the key will persist until explicitly deleted using the Del interface.

ExistenceOpt existence = ExistenceOpt::NX#

Existence option.

Determines if the key allows repeated writes. Optional parameters: YR::ExistenceOpt::NX (allow, default) and YR::ExistenceOpt::NONE (do not allow). Default value: YR::ExistenceOpt::NX.

CacheType cacheType = CacheType::MEMORY#

Cache type.

Specifies whether the data is allocated to memory or disk. Optional parameters: YR::CacheType::Memory (memory) and YR::CacheType::Disk (disk). Default value: YR::CacheType::Memory.

std::unordered_map<std::string, std::string> extendParams#

Extended parameters.

Configures additional parameters beyond those specified above