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

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

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

woody712 opened this issue Aug 19, 2019 · 10 comments
Labels
good first issue A user wrote a good first issue with clear instructions 🚀 status:implemented 🪶 type: feature
Milestone

Comments

@woody712
Copy link

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
Copy link
Owner

kataras 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
Copy link
Contributor

majidbigdeli 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
Copy link
Owner

kataras 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
Copy link
Owner

kataras 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
Copy link
Contributor

majidbigdeli 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
Copy link
Owner

kataras 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
Copy link
Contributor

majidbigdeli 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
Copy link
Contributor

I saw this comment.
Bravo . it is true

@kataras
Copy link
Owner

kataras 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
Copy link
Author

Thx all above

@kataras kataras added 🚀 status:implemented 🪶 type: feature good first issue A user wrote a good first issue with clear instructions and removed 🕰 status:in-progress labels Sep 25, 2019
@kataras kataras closed this as completed Sep 25, 2019
@kataras kataras added this to the v12.0.0 milestone Oct 26, 2019
github-actions bot pushed a commit to goproxies/github.com-kataras-iris that referenced this issue Jul 27, 2020
Former-commit-id: d748d1e19a29851abbbfc0264fd04c462158b645
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue A user wrote a good first issue with clear instructions 🚀 status:implemented 🪶 type: feature
Projects
None yet
Development

No branches or pull requests

3 participants