Comments (3)
Ah I should do a better job documenting this, but RedisMap
was built to be a NewType in order to support generic inputs on certain functions. It is designed to be used as an intermediate type so callers can use HashMap
or BTreeMap
, but it's rare for a caller to need to manually construct a RedisMap
by hand.
In your case you can probably collapse that code into this:
let _: () = redis_client.set("foo_key", 123, Some(Expiration::EX(10), None, false).await?;
Or, if you did mean to encode a map into a non-nested type like SET, you would need to serialize it to some format, such as JSON, or something like that. Or, you could use HSET which supports nested maps:
let mut values: HashMap<String, i64> = HashMap::new(); // or BTreeMap, etc
values.insert("foo_key".into(), 123);
let _: () = redis_client.hset("KEYS", values).await?;
A quick note on the NewType values such as RedisMap
- they are not as easy to use in the current 4.3.2 version on crates.io as I'd like. I'm a few days away from releasing 5.0.0 which makes some big ergonomics improvements to these types, and these interfaces should be easier to use then.
from fred.rs.
I found I can not set Expiration
with hset
, How to do that as set
?
from fred.rs.
The hset
command seems what I want, Thanks.
from fred.rs.
Related Issues (20)
- Stack usage HOT 2
- SORT or SORT_RO missing HOT 3
- [Bug] - Build error when building with the partial-tracing feature HOT 2
- [Bug]Questions about library selection HOT 1
- [Bug] Cannot return integer type from `exists` HOT 4
- [Bug]When a Redis cluster's primary machine fails and a standby Redis node takes over, it takes too long for Fred to rediscover and connect to the new primary. HOT 3
- add support for Redis Cluster pipeline HOT 6
- [Bug] Using Sentinel to connect to redis, I always get a timeout error HOT 2
- 9.0.1 In sentinel mode with resp3 : ERR: Protocol Error: Cannot start a stream while already inside a stream[Bug] HOT 1
- Error referencing const within util HOT 2
- [Bug] Certain ranges are not accepted in BYSCORE zranges HOT 1
- [Bug] Transactions with WATCH/UNWATCH do not work HOT 2
- [Bug] json_set is not working for string values HOT 1
- [Bug] `WithOptions` is lost when you use `.replicas()` HOT 3
- [Bug] hmset doesn't work with optional values
- [Feature] Exponential backoff to reconnect if Redis was not running initially HOT 2
- [Bug] `.replicas()` doesn't work with centralized Redis HOT 3
- [Feature] Enabling the Redisearch interface through Cargo HOT 2
- [Feature] Replace `trust-dns-resolver` with `hickory-resolver` HOT 2
- [Feature] Options for `EXPIRE` commands
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fred.rs.