#RUST: Redis JSON key generation

2 messages · Page 1 of 1 (latest)

dusty crown
#

Hi Everyone,
I'm struggling finding a solution how to efficiently store my data into Redis by building key using the values inside the json, to avoid risk of overwriting the data.

Current flow is Webscocket messages (50k msg per sec) -> in Redis.
project is built in Rust, currently my code is deserializing each JSON message to build the key.

My code accesses nested fields within this serde_json::Value using methods like .get(), .and_then(), and .as_str() or .as_u64() to extract values such as header.type, contract.security_type, contract.root, etc. from my ws messages.

I thought about reducing the delays from deserializing by UUID each key, and then rename the keys with LUA, but not sure it's that easy to rename keys async.

Samples: {"header":{"type":"TRADE","status":"CONNECTED"},"contract":{"security_type":"OPTION","root":"META","expiration":20240920,"strike":585000,"right":"C"},"trade":{"ms_of_day":48650986,"sequence":472514108,"size":1,"condition":18,"price":3.65,"exchange":65,"date":20240809}} {"header":{"type":"QUOTE","status":"CONNECTED"},"contract":{"security_type":"OPTION","root":"META","expiration":20240920,"strike":585000,"right":"C"},"quote":{"ms_of_day":48650986,"bid_size":142,"bid_exchange":5,"bid":3.55,"bid_condition":50,"ask_size":39,"ask_exchange":1,"ask":3.7,"ask_condition":50,"date":20240809}}

#

RUST: Redis JSON key generation