mirror of
https://github.com/EchoVault/SugarDB.git
synced 2025-10-05 07:56:52 +08:00
feat: INCR command added
This commit is contained in:
@@ -15,9 +15,10 @@
|
||||
package echovault
|
||||
|
||||
import (
|
||||
"github.com/echovault/echovault/internal"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/echovault/echovault/internal"
|
||||
)
|
||||
|
||||
// SetOptions modifies the behaviour for the Set command
|
||||
@@ -416,3 +417,17 @@ func (server *EchoVault) PExpireAt(key string, unixMilliseconds int, options PEx
|
||||
|
||||
return internal.ParseIntegerResponse(b)
|
||||
}
|
||||
|
||||
func (server *EchoVault) Incr(key string) (int, error) {
|
||||
// Construct the command
|
||||
cmd := []string{"INCR", key}
|
||||
|
||||
// Execute the command
|
||||
b, err := server.handleCommand(server.context, internal.EncodeCommand(cmd), nil, false, true)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Parse the integer response
|
||||
return internal.ParseIntegerResponse(b)
|
||||
}
|
||||
|
Reference in New Issue
Block a user