mirror of
https://github.com/gofiber/storage.git
synced 2025-10-05 16:48:25 +08:00
Update sqlite3.go
This commit is contained in:
@@ -93,21 +93,19 @@ func New(config ...Config) *Storage {
|
|||||||
return store
|
return store
|
||||||
}
|
}
|
||||||
|
|
||||||
var noRows = "sql: no rows in result set"
|
|
||||||
|
|
||||||
// Get value by key
|
// Get value by key
|
||||||
func (s *Storage) Get(key string) ([]byte, error) {
|
func (s *Storage) Get(key string) ([]byte, error) {
|
||||||
row := s.db.QueryRow(s.sqlSelect, key)
|
row := s.db.QueryRow(s.sqlSelect, key)
|
||||||
|
|
||||||
|
if row.Err() == sql.ErrNoRows {
|
||||||
|
return nil, ErrNotExist
|
||||||
|
}
|
||||||
// Add db response to data
|
// Add db response to data
|
||||||
var (
|
var (
|
||||||
data = []byte{}
|
data = []byte{}
|
||||||
exp int64 = 0
|
exp int64 = 0
|
||||||
)
|
)
|
||||||
if err := row.Scan(&data, &exp); err != nil {
|
if err := row.Scan(&data, &exp); err != nil {
|
||||||
if err.Error() != noRows {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user