January 2019
Intermediate to advanced
520 pages
14h 32m
English
The GetValue struct represents a message to extract a value from Redis by key (or path, in our case). It contains only one field with a path value:
struct GetValue { pub path: String,}
We also have to implement the Message trait to it, but we want it to return an optional Vec<u8> value if Redis contains a value for the provided key:
impl Message for GetValue { type Result = Result<Option<Vec<u8>>, RedisError>;}
CacheActor also implements a Handler trait for the GetValue message type, and uses the GET command of Redis storage by calling the get method of Client to extract a value from storage:
impl Handler<GetValue> for CacheActor { type Result = Result<Option<Vec<u8>>, RedisError>; fn handle(&mut self, msg: GetValue, ...Read now
Unlock full access