mirror of
https://github.com/gofiber/storage.git
synced 2025-10-04 16:22:52 +08:00
zzz
This commit is contained in:
@@ -99,7 +99,7 @@ func New(config ...Config) *Storage {
|
||||
db: db,
|
||||
gcInterval: cfg.GCInterval,
|
||||
sqlSelect: fmt.Sprintf(`SELECT data, exp FROM %s WHERE key=$1;`, cfg.Table),
|
||||
sqlInsert: fmt.Sprintf("INSERT OR REPLACE INTO %s (key, data, exp) VALUES ($1, $2, $3)", cfg.Table),
|
||||
sqlInsert: fmt.Sprintf(`INSERT INTO %s (key, data, exp) VALUES ($1, $2, $3) ON DUPLICATE KEY UPDATE data="$1", exp=$3`, cfg.Table),
|
||||
sqlDelete: fmt.Sprintf("DELETE FROM %s WHERE key=$1", cfg.Table),
|
||||
sqlClear: fmt.Sprintf("DELETE FROM %s;", cfg.Table),
|
||||
sqlGC: fmt.Sprintf("DELETE FROM %s WHERE exp <= $1", cfg.Table),
|
||||
@@ -122,10 +122,10 @@ func (s *Storage) Get(key string) ([]byte, error) {
|
||||
exp int64 = 0
|
||||
)
|
||||
if err := row.Scan(&data, &exp); err != nil {
|
||||
if err != noRows {
|
||||
return nil, err
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, ErrNotExist
|
||||
}
|
||||
return nil, nil
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// If the expiration time has already passed, then return nil
|
||||
|
Reference in New Issue
Block a user