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

Would you like to support redis cluster in session? #1339

Open
woody712 opened this issue Aug 19, 2019 · 10 comments

Comments

@woody712
Copy link

commented Aug 19, 2019

Though the connection pool of inner built is enough in most conditions, I still want to use sessions with redis cluster, because of my company's existing cluster

@kataras

This comment has been minimized.

Copy link
Owner

commented Aug 19, 2019

Hello @woody712,

If your company uses redis and redis clusters then you can just create your custom redis sessiondb (see: https://github.com/kataras/iris/tree/master/sessions/sessiondb/redis for implementation) or edit the existing one, test and push a PR, I can do it but I can't directly test it, so i think it's better to let that for you or a co-worker of yours.

@majidbigdeli

This comment has been minimized.

Copy link
Contributor

commented Aug 20, 2019

@woody712 , @kataras

I can do it with radix but does redigo support it?

radix has many features and its code is clean.

@kataras

This comment has been minimized.

Copy link
Owner

commented Aug 20, 2019

redigo does not support cluster, it has another library for it. Radix can support and I already did it locally(update: pushed to master) but it is slow on scan with prefix (the method that sessiondb uses to fetch values)...I will see what I can do and we can compare our versions and push the better implementation one into Iris.

kataras added a commit that referenced this issue Aug 20, 2019
@kataras

This comment has been minimized.

Copy link
Owner

commented Aug 20, 2019

@woody712 You can use clusters now with Config.Clusters field but only if Config.Driver is sessiondb/redis.Radix() ( at least for now).

@majidbigdeli

This comment has been minimized.

Copy link
Contributor

commented Aug 20, 2019

but it is slow on scan with prefix (the method that sessiondb uses to fetch values)

@kataras
yes. Sometimes radix has some problems too.
for example

when I Use "SET" Action to store a large number of key - values at a time. it is slow

or can not use "MSET" Action to store Struct
Issue

for example

err := client.Do(radix.FlatCmd(nil, "MSET","Key", Struct{
    firstname"val1",
    lastname: "val2",
})

but radix code is clean with good feature for example
it is very good Support for pubsub,

@kataras

This comment has been minimized.

Copy link
Owner

commented Aug 20, 2019

Yes this is why it's used on neffos that pubsub was requirement as I explained back then, but in Iris session databases we don't need this feature. However, about my above comment on slow on get keys of radix, I found the issue: #1328 (comment)

@majidbigdeli

This comment has been minimized.

Copy link
Contributor

commented Aug 20, 2019

@kataras for #1328
i found this https://github.com/mediocregopher/radix/blob/master/scanner.go

// ScanOpts are various parameters which can be passed into ScanWithOpts. Some
// fields are required depending on which type of scan is being done.
type ScanOpts struct {
	// The scan command to do, e.g. "SCAN", "HSCAN", etc...
	Command string

	// The key to perform the scan on. Only necessary when Command isn't "SCAN"
	Key string

	// An optional pattern to filter returned keys by
	Pattern string

	// An optional count hint to send to redis to indicate number of keys to
	// return per call. This does not affect the actual results of the scan
	// command, but it may be useful for optimizing certain datasets
	Count int
}

for 100000 key
Just enough Set count to 100000

An optional count hint to send to redis to indicate number of keys to
return per call. This does not affect the actual results of the scan
command, but it may be useful for optimizing certain datasets

@majidbigdeli

This comment has been minimized.

Copy link
Contributor

commented Aug 20, 2019

I saw this comment.
Bravo . it is true

@kataras

This comment has been minimized.

Copy link
Owner

commented Aug 20, 2019

Yeah @majidbigdeli thank you, I pushed the commit. The COUNT is 300 thousand and it iterates until cursor returned by redis is 0 (when iteration is done/ it's full iter) I also added an improvement on the redigo driver one (before it was limited to nine billion nine hundred ninety nine million nine hundred ninety nine thousand nine hundred ninety nine).

@woody712

This comment has been minimized.

Copy link
Author

commented Aug 21, 2019

Thx all above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.