-
Notifications
You must be signed in to change notification settings - Fork 16
Conversation
If a command is not available via the Redis Rust client you can use |
@tbmreza I havent tested it out extensively but according to the redis-rs docs changes the state of the connection or something, and my test for the GETDEL command only behaved as expected when I called get twice. I just gave up testing that out because no Redis client I've seen implements GETDEL and it's deprecated apparently. see my comment here |
I think the python redis client does implement TYPE unlike redis-rs. You could test it out with that, because send_packed_command just ignores the response from the server. |
redisless/storage/src/in_memory.rs
Outdated
fn value_type(&mut self, key: &[u8]) -> String { | ||
if let Some(data_type) = self.data_mapper.get(key) { | ||
match data_type { | ||
DataType::String => format!("string"), | ||
DataType::List => format!("list"), | ||
DataType::Set => format!("set"), | ||
DataType::Hash => format!("hash"), | ||
} | ||
} else { | ||
format!("none") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to use "string".to_string()
here since u don't actually need to format
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also you can match directly on the Some inner type like Some(DataType::String) => ...
, that way you can match directly on the datamapper.get and avoid nesting it like that with an if let. Also I think it's better if you return a &str
from value_type, that way you don't need to allocate a whole String
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@clarity0 Got it. I have just:
- changed the return type to &str
- matched directly without if let nest
- added the command in the python client
Is that everything?
Does it work well with the python client? |
Should I test it thoroughly? If so, do I put them (SET and TYPE commands for every DataType) all in main.py? @clarity0 |
for the 1 TYPE command I tested in python client, yes it works well (the assertion doesn't fail) |
Right now there is only support commands that add strings so you can't really test the other cases with a client but they should work fine. |
@tbmreza can you rebase? |
sure but I'm not a capable git user. could you tell me how to do it, step by step? |
How do you test a new command? I'm not sure if I'm already on the right direction, i.e., if I only need to figure out what to feed
send_packed_command()
with, and how to receive the connection's response.#28