storage
storage copied to clipboard
[FEATURE] - Add functions: incr, incrBy, incrByFloat
Along with Set
and Get
it's better introduce some more functions for data integrity and most of the databases already support above functions.
Some functions:
- incr
- incrBy
- incrByFloat
- expire
@ReneWerner87 @hi019 what do you think about that? I think 1, 2, 3. options would be great.
Well I'm not that excited, for me these are just key value storages and more than fetch or set is not needed from my point of view.
But that's just my opinion and I like to be overvote or convinced
Oh, I came because I needed an INCR... It is shocking to see that the issue was a year and three months ago.
It seems inevitable that I will have to open two REDIS sessions.
Oh, I came because I needed an INCR... It is shocking to see that the issue was a year and three months ago.
It seems inevitable that I will have to open two REDIS sessions.
You can use https://github.com/gofiber/storage/blob/main/redis/redis.go#L104
@efectn Thanks
access to the db connection is introduced in #451
@sujit-baniya do we still need the feature, can you give specific examples of how to use it and when to use it
i think the important thing is that we have now allowed the initalized connection to be used again
@ReneWerner87 Yes I think these features: incr
, incrBy
and incrByFloat
will serve high purpose of usability. It's true that for Redis storage we could use Conn()
function to get client connection to do stuffs. I purpose to implement these features in all drivers
But since we have Storage
interface, most of the developers will use the interface instead of specific driver. That's why I purpose to add these features in interface.
Some of the use cases
- Manage the metrics by increasing the value on key
- Managing item counter in queues
For e.g.
I'm building SMS Application and it requires to update SMS counts per user. I plan to use gofiber/storage
. Since it supports multiple driver, I could easily switch to any drivers I wanted. And if I've mentioned features in gofiber/storage
interface, I would not need to create connections again per driver (it will create a lot mess then)
@sujit-baniya PR #451 now allows you to get the Conn from any of the storage drivers, not just Redis. Does that help?
@gaby That would help a lot. Thanks :)
@sujit-baniya Let me know if this can be closed :-) Thanks!