mirror of
https://github.com/lukaszraczylo/traefikoidc.git
synced 2026-10-14 04:07:46 +00:00
Add redis support for distributed caching (#83)
* Add redis support for distributed caching * Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * fixup! fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * fixup! fixup! fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * fixup! fixup! fixup! fixup! fixup! Move towards the self-provided Redis connection pool and RESP protocol implementation. Official redis client library won't work with yaegi. * ... and another all nighter. * fixup! ... and another all nighter. * fixup! fixup! ... and another all nighter. * fixup! fixup! fixup! ... and another all nighter. * Resolve issue #85 by adding ability to set custom claims in JWT tokens * Remove redundant validation in auth middleware ( issue #89 ) * Add ability to set cookie prefix for session cookies ( #87 ) * fixup! Add ability to set cookie prefix for session cookies ( #87 ) * Add ability to set cookie max age - issue #91 * Potential fix for code scanning alert no. 10: Size computation for allocation may overflow Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> * fixup! Merge main into 0.8.0-redis: resolve conflicts --------- Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
parent
5fcbd54955
commit
e64fc7f730
+68
@@ -0,0 +1,68 @@
|
||||
package miniredis
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/alicebob/miniredis/v2/server"
|
||||
)
|
||||
|
||||
// commandsClient handles client operations.
|
||||
func commandsClient(m *Miniredis) {
|
||||
m.srv.Register("CLIENT", m.cmdClient)
|
||||
}
|
||||
|
||||
// CLIENT
|
||||
func (m *Miniredis) cmdClient(c *server.Peer, cmd string, args []string) {
|
||||
if len(args) == 0 {
|
||||
setDirty(c)
|
||||
c.WriteError("ERR wrong number of arguments for 'client' command")
|
||||
return
|
||||
}
|
||||
|
||||
withTx(m, c, func(c *server.Peer, ctx *connCtx) {
|
||||
switch cmd := strings.ToUpper(args[0]); cmd {
|
||||
case "SETNAME":
|
||||
m.cmdClientSetName(c, args[1:])
|
||||
case "GETNAME":
|
||||
m.cmdClientGetName(c, args[1:])
|
||||
default:
|
||||
setDirty(c)
|
||||
c.WriteError(fmt.Sprintf("ERR unknown subcommand '%s'. Try CLIENT HELP.", cmd))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// CLIENT SETNAME
|
||||
func (m *Miniredis) cmdClientSetName(c *server.Peer, args []string) {
|
||||
if len(args) != 1 {
|
||||
setDirty(c)
|
||||
c.WriteError("ERR wrong number of arguments for 'client setname' command")
|
||||
return
|
||||
}
|
||||
|
||||
name := args[0]
|
||||
if strings.ContainsAny(name, " \n") {
|
||||
setDirty(c)
|
||||
c.WriteError("ERR Client names cannot contain spaces, newlines or special characters.")
|
||||
return
|
||||
|
||||
}
|
||||
c.ClientName = name
|
||||
c.WriteOK()
|
||||
}
|
||||
|
||||
// CLIENT GETNAME
|
||||
func (m *Miniredis) cmdClientGetName(c *server.Peer, args []string) {
|
||||
if len(args) > 0 {
|
||||
setDirty(c)
|
||||
c.WriteError("ERR wrong number of arguments for 'client getname' command")
|
||||
return
|
||||
}
|
||||
|
||||
if c.ClientName == "" {
|
||||
c.WriteNull()
|
||||
} else {
|
||||
c.WriteBulk(c.ClientName)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user