yr.kv_write_with_param#
- yr.kv_write_with_param(key: str, value: bytes, set_param: SetParam) None[source]#
Provide a storage interface that supports custom parameter configuration, enabling binary data to be written to the data system in a more flexible manner.
- Parameters:
key (str) – Sets a key for the data to be saved, which is used to identify the data. This key is used for querying the data and cannot be empty.
value (bytes) – The binary data to be stored. The maximum storage limit is 100M outside the cloud.
set_param (SetParam) – Configuration parameters for kv write in the data system, including existence, write_mode, ttl_second, and cache_type.
- Returns:
None.
- Raises:
RuntimeError – If kv_write_with_param is called without initialization, an exception will be thrown.
RuntimeError – If the data fails to be written to the data system.
Example
>>> import yr >>> yr.init() >>> # The worker startup parameters need to be configured with shared_disk_directory and shared_disk_size_mb; >>> # otherwise, this example will result in an error >>> set_param = yr.SetParam() >>> set_param.existence = yr.ExistenceOpt.NX >>> set_param.write_mode = yr.WriteMode.NONE_L2_CACHE_EVICT >>> set_param.ttl_second = 10 >>> yr.kv_write_with_param("kv-key", b"value1", set_param) >>> >>> yr.finalize()