mirror of
https://github.com/kataras/iris.git
synced 2026-01-21 02:45:59 +00:00
update dependencies
This commit is contained in:
@@ -165,7 +165,7 @@ func (db *Database) OnUpdateExpiration(sid string, newExpires time.Duration) err
|
||||
|
||||
// Set sets a key value of a specific session.
|
||||
// Ignore the "immutable".
|
||||
func (db *Database) Set(sid string, key string, value interface{}, _ time.Duration, _ bool) error {
|
||||
func (db *Database) Set(sid string, key string, value any, _ time.Duration, _ bool) error {
|
||||
valueBytes, err := sessions.DefaultTranscoder.Marshal(value)
|
||||
if err != nil {
|
||||
db.logger.Error(err)
|
||||
@@ -181,7 +181,7 @@ func (db *Database) Set(sid string, key string, value interface{}, _ time.Durati
|
||||
}
|
||||
|
||||
// Get retrieves a session value based on the key.
|
||||
func (db *Database) Get(sid string, key string) (value interface{}) {
|
||||
func (db *Database) Get(sid string, key string) (value any) {
|
||||
if err := db.Decode(sid, key, &value); err == nil {
|
||||
return value
|
||||
}
|
||||
@@ -190,7 +190,7 @@ func (db *Database) Get(sid string, key string) (value interface{}) {
|
||||
}
|
||||
|
||||
// Decode binds the "outPtr" to the value associated to the provided "key".
|
||||
func (db *Database) Decode(sid, key string, outPtr interface{}) error {
|
||||
func (db *Database) Decode(sid, key string, outPtr any) error {
|
||||
sidKey := db.makeSID(sid)
|
||||
data, err := db.c.Driver.Get(sidKey, key)
|
||||
if err != nil {
|
||||
@@ -206,7 +206,7 @@ func (db *Database) Decode(sid, key string, outPtr interface{}) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (db *Database) decodeValue(val interface{}, outPtr interface{}) error {
|
||||
func (db *Database) decodeValue(val any, outPtr any) error {
|
||||
if val == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -234,14 +234,14 @@ func (db *Database) keys(fullSID string) []string {
|
||||
}
|
||||
|
||||
// Visit loops through all session keys and values.
|
||||
func (db *Database) Visit(sid string, cb func(key string, value interface{})) error {
|
||||
func (db *Database) Visit(sid string, cb func(key string, value any)) error {
|
||||
kv, err := db.c.Driver.GetAll(db.makeSID(sid))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for k, v := range kv {
|
||||
var value interface{} // new value each time, we don't know what user will do in "cb".
|
||||
var value any // new value each time, we don't know what user will do in "cb".
|
||||
if err = db.decodeValue(v, &value); err != nil {
|
||||
db.logger.Debugf("unable to decode %s:%s: %v", sid, k, err)
|
||||
return err
|
||||
|
||||
@@ -8,8 +8,8 @@ type Driver interface {
|
||||
Connect(c Config) error
|
||||
PingPong() (bool, error)
|
||||
CloseConnection() error
|
||||
Set(sid, key string, value interface{}) error
|
||||
Get(sid, key string) (interface{}, error)
|
||||
Set(sid, key string, value any) error
|
||||
Get(sid, key string) (any, error)
|
||||
Exists(sid string) bool
|
||||
TTL(sid string) time.Duration
|
||||
UpdateTTL(sid string, newLifetime time.Duration) error
|
||||
|
||||
@@ -150,12 +150,12 @@ func (r *GoRedisDriver) CloseConnection() error {
|
||||
|
||||
// Set stores a "value" based on the session's "key".
|
||||
// The value should be type of []byte, so unmarshal can happen.
|
||||
func (r *GoRedisDriver) Set(sid, key string, value interface{}) error {
|
||||
func (r *GoRedisDriver) Set(sid, key string, value any) error {
|
||||
return r.Client.HSet(defaultContext, sid, key, value).Err()
|
||||
}
|
||||
|
||||
// Get returns the associated value of the session's given "key".
|
||||
func (r *GoRedisDriver) Get(sid, key string) (interface{}, error) {
|
||||
func (r *GoRedisDriver) Get(sid, key string) (any, error) {
|
||||
return r.Client.HGet(defaultContext, sid, key).Bytes()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user