Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not using value parameter #14

Open
gozeloglu opened this issue May 15, 2022 · 4 comments
Open

Not using value parameter #14

gozeloglu opened this issue May 15, 2022 · 4 comments

Comments

@gozeloglu
Copy link
Contributor

Hi,

I've seen that value is not being used in here. Is there any reason to not use the value parameter? If you miss to use it, I can fix it.

@arriqaaq
Copy link
Owner

Thank you for the comment @gozeloglu

The SetEx method is currently implemented on the key. The idea is that as follows

set foo bar #for setting value
setex foo 15. #for setting expiry

We could definitely combine this into a single command, what do you think?

@gozeloglu
Copy link
Contributor Author

The SetEx method is currently implemented on the key.

What do you mean by this? Where is the key?

We could definitely combine this into a single command, what do you think?

Do you mean by combining Set and SetEx with a single command? If yes, I think it's not a good idea, because the commands' purposes are different.

@arriqaaq
Copy link
Owner

What do you mean by this? Where is the key?

The SetEx method would only use key in the params in the function

We could definitely combine this into a single command, what do you think?
Redis already has a setex command which does the same

https://redis.io/commands/setex/

@glycerine
Copy link

glycerine commented Feb 22, 2025

I think what gozeloglu meant was that

https://github.com/arriqaaq/flashdb/blob/main/tx_str.go#L22

looks like a simple omission bug, where

e := newRecordWithExpire([]byte(key), nil, ttl, StringRecord, StringExpire)

should be changed to actually record the value as well as the key and TTL.

Otherwise the signature and documentation make no sense. The value
is lost and cannot be looked up by that key.

// SetEx sets key-value pair with given duration time for expiration.
func (tx *Tx) SetEx(key string, value string, duration int64) (err error) 

So it very much looks like a bug in the implimentation of SetEx.

p.s. Thank you for publishing this package. It looks delightful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants