1
0
mirror of https://github.com/kataras/iris.git synced 2026-01-09 13:05:56 +00:00

formatting

Former-commit-id: 037081db5d6d4434e873ca8b75334ee43e046b6a
This commit is contained in:
Gerasimos (Makis) Maropoulos
2019-08-17 10:06:20 +03:00
parent 00967408dc
commit 07046ab978
112 changed files with 477 additions and 517 deletions

View File

@@ -120,7 +120,6 @@ type (
// Validate corrects missing fields configuration fields and returns the right configuration
func (c Config) Validate() Config {
if c.Cookie == "" {
c.Cookie = DefaultCookieName
}

View File

@@ -62,7 +62,6 @@ func New(directoryPath string) (*Database, error) {
opts := badger.DefaultOptions(directoryPath)
service, err := badger.Open(opts)
if err != nil {
golog.Errorf("unable to initialize the badger-based session database: %v", err)
return nil, err
@@ -97,7 +96,6 @@ func (db *Database) Acquire(sid string, expires time.Duration) sessions.LifeTime
if err == badger.ErrKeyNotFound {
// create it and set the expiration, we don't care about the value there.
err = txn.SetEntry(badger.NewEntry(bsid, bsid).WithTTL(expires))
}
}
@@ -192,7 +190,6 @@ func (db *Database) Visit(sid string, cb func(key string, value interface{})) {
err := item.Value(func(valueBytes []byte) error {
return sessions.DefaultTranscoder.Unmarshal(valueBytes, &value)
})
if err != nil {
golog.Error(err)
continue

View File

@@ -55,7 +55,6 @@ func New(path string, fileMode os.FileMode) (*Database, error) {
service, err := bolt.Open(path, fileMode,
&bolt.Options{Timeout: 20 * time.Second},
)
if err != nil {
golog.Errorf("unable to initialize the BoltDB-based session database: %v", err)
return nil, err
@@ -203,7 +202,6 @@ func (db *Database) Acquire(sid string, expires time.Duration) (lifetime session
_, err = root.CreateBucketIfNotExists(bsid)
return
})
if err != nil {
golog.Debugf("unable to acquire session '%s': %v", sid, err)
return sessions.LifeTime{}
@@ -285,7 +283,6 @@ func (db *Database) Get(sid string, key string) (value interface{}) {
return sessions.DefaultTranscoder.Unmarshal(valueBytes, &value)
})
if err != nil {
golog.Debugf("session '%s' key '%s' not found", sid, key)
}

View File

@@ -134,7 +134,6 @@ func (db *Database) Acquire(sid string, expires time.Duration) sessions.LifeTime
if !hasExpiration {
return sessions.LifeTime{}
}
return sessions.LifeTime{Time: time.Now().Add(time.Duration(seconds) * time.Second)}

View File

@@ -114,13 +114,12 @@ func (r *RadixDriver) Set(key string, value interface{}, secondsLifetime int64)
}
// Get returns value, err by its key
//returns nil and a filled error if something bad happened.
// returns nil and a filled error if something bad happened.
func (r *RadixDriver) Get(key string) (interface{}, error) {
var redisVal interface{}
mn := radix.MaybeNil{Rcv: &redisVal}
err := r.pool.Do(radix.Cmd(&mn, "GET", r.Config.Prefix+key))
if err != nil {
return nil, err
}
@@ -197,7 +196,6 @@ func (r *RadixDriver) GetAll() (interface{}, error) {
var redisVal []interface{}
mn := radix.MaybeNil{Rcv: &redisVal}
err := r.pool.Do(radix.Cmd(&mn, "SCAN", strconv.Itoa(0))) // 0 -> cursor
if err != nil {
return nil, err
}

View File

@@ -70,7 +70,7 @@ func (r *RedigoDriver) Set(key string, value interface{}, secondsLifetime int64)
}
// Get returns value, err by its key
//returns nil and a filled error if something bad happened.
// returns nil and a filled error if something bad happened.
func (r *RedigoDriver) Get(key string) (interface{}, error) {
c := r.pool.Get()
defer c.Close()
@@ -79,7 +79,6 @@ func (r *RedigoDriver) Get(key string) (interface{}, error) {
}
redisVal, err := c.Do("GET", r.Config.Prefix+key)
if err != nil {
return nil, err
}
@@ -108,7 +107,6 @@ func (r *RedigoDriver) TTL(key string) (seconds int64, hasExpiration bool, found
func (r *RedigoDriver) updateTTLConn(c redis.Conn, key string, newSecondsLifeTime int64) error {
reply, err := c.Do("EXPIRE", r.Config.Prefix+key, newSecondsLifeTime)
if err != nil {
return err
}
@@ -175,7 +173,6 @@ func (r *RedigoDriver) GetAll() (interface{}, error) {
}
redisVal, err := c.Do("SCAN", 0) // 0 -> cursor
if err != nil {
return nil, err
}
@@ -234,7 +231,7 @@ func (r *RedigoDriver) GetKeys(prefix string) ([]string, error) {
// GetBytes returns value, err by its key
// you can use utils.Deserialize((.GetBytes("yourkey"),&theobject{})
//returns nil and a filled error if something wrong happens
// returns nil and a filled error if something wrong happens
func (r *RedigoDriver) GetBytes(key string) ([]byte, error) {
c := r.pool.Get()
defer c.Close()
@@ -243,7 +240,6 @@ func (r *RedigoDriver) GetBytes(key string) ([]byte, error) {
}
redisVal, err := c.Do("GET", r.Config.Prefix+key)
if err != nil {
return nil, err
}