MM-8602: KV Store Json helper tweaks (#11502)
* move kv helpers to helpers_kv*.go * change KVGetJSON return signature Return a boolean and an error, to clearly indicate if no value was found and thus no value unmarshalled into the target interface. Also fix an issue with CompareAndSet to allow an oldValue of nil (i.e. expected to be unset). * add missing license * tweak documentation * document KVSetWithExpiryJSON minimum version
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
c34942afec
Коммит
620d941b6e
@@ -456,37 +456,36 @@ type API interface {
|
||||
|
||||
// KV Store Section
|
||||
|
||||
// KVSet will store a key-value pair, unique per plugin.
|
||||
// KVSet stores a key-value pair, unique per plugin.
|
||||
// Provided helper functions and internal plugin code will use the prefix `mmi_` before keys. Do not use this prefix.
|
||||
KVSet(key string, value []byte) *model.AppError
|
||||
|
||||
// KVCompareAndSet will update a key-value pair,
|
||||
// unique per plugin, to the given new value if the current value == the old value.
|
||||
// KVCompareAndSet updates a key-value pair, unique per plugin, but only if the current value matches the given oldValue.
|
||||
// Inserts a new key if oldValue == nil.
|
||||
// Returns (false, err) if DB error occurred
|
||||
// Returns (false, nil) if current value != old value or key already exists when inserting
|
||||
// Returns (true, nil) if current value == old value or new key is inserted
|
||||
// Returns (false, nil) if current value != oldValue or key already exists when inserting
|
||||
// Returns (true, nil) if current value == oldValue or new key is inserted
|
||||
//
|
||||
// Minimum server version: 5.12
|
||||
KVCompareAndSet(key string, oldValue, newValue []byte) (bool, *model.AppError)
|
||||
|
||||
// KVSet will store a key-value pair, unique per plugin with an expiry time
|
||||
// KVSet stores a key-value pair with an expiry time, unique per plugin.
|
||||
//
|
||||
// Minimum server version: 5.6
|
||||
KVSetWithExpiry(key string, value []byte, expireInSeconds int64) *model.AppError
|
||||
|
||||
// KVGet will retrieve a value based on the key. Returns nil for non-existent keys.
|
||||
// KVGet retrieves a value based on the key, unique per plugin. Returns nil for non-existent keys.
|
||||
KVGet(key string) ([]byte, *model.AppError)
|
||||
|
||||
// KVDelete will remove a key-value pair. Returns nil for non-existent keys.
|
||||
// KVDelete removes a key-value pair, unique per plugin. Returns nil for non-existent keys.
|
||||
KVDelete(key string) *model.AppError
|
||||
|
||||
// KVDeleteAll will remove all key-value pairs for a plugin.
|
||||
// KVDeleteAll removes all key-value pairs for a plugin.
|
||||
//
|
||||
// Minimum server version: 5.6
|
||||
KVDeleteAll() *model.AppError
|
||||
|
||||
// KVList will list all keys for a plugin.
|
||||
// KVList lists all keys for a plugin.
|
||||
//
|
||||
// Minimum server version: 5.6
|
||||
KVList(page, perPage int) ([]string, *model.AppError)
|
||||
|
||||
Ссылка в новой задаче
Block a user