DeleteAll for KV (#9431)
Expire K/V Values Regenerate Code pathfix Update Expiry on Update Check for Exit Signal gofmt Rewrote Go Routine Remove tempoarily cleanup loop fix expiretime TEST: Expired Watchdog as GoRoutine Check if Srv is nil Use Scheduler/Worker for Expired Key CleanUp add license fix scheduler job type; DoJob Restructuring Remove unused imports and constants move db migration from 5.4 to 5.5
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
bd04d7f756
Коммит
c36e85c912
@@ -19,10 +19,20 @@ func getKeyHash(key string) string {
|
||||
}
|
||||
|
||||
func (a *App) SetPluginKey(pluginId string, key string, value []byte) *model.AppError {
|
||||
return a.SetPluginKeyWithExpiry(pluginId, key, value, 0)
|
||||
}
|
||||
|
||||
func (a *App) SetPluginKeyWithExpiry(pluginId string, key string, value []byte, expireInSeconds int64) *model.AppError {
|
||||
|
||||
if expireInSeconds > 0 {
|
||||
expireInSeconds = model.GetMillis() + (expireInSeconds * 1000)
|
||||
}
|
||||
|
||||
kv := &model.PluginKeyValue{
|
||||
PluginId: pluginId,
|
||||
Key: getKeyHash(key),
|
||||
Value: value,
|
||||
ExpireAt: expireInSeconds,
|
||||
}
|
||||
|
||||
result := <-a.Srv.Store.Plugin().SaveOrUpdate(kv)
|
||||
@@ -60,6 +70,31 @@ func (a *App) DeletePluginKey(pluginId string, key string) *model.AppError {
|
||||
return result.Err
|
||||
}
|
||||
|
||||
func (a *App) DeleteAllKeysForPlugin(pluginId string) *model.AppError {
|
||||
result := <-a.Srv.Store.Plugin().DeleteAllForPlugin(pluginId)
|
||||
|
||||
if result.Err != nil {
|
||||
mlog.Error(result.Err.Error())
|
||||
}
|
||||
|
||||
return result.Err
|
||||
}
|
||||
|
||||
func (a *App) DeleteAllExpiredPluginKeys() *model.AppError {
|
||||
|
||||
if a.Srv == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
result := <-a.Srv.Store.Plugin().DeleteAllExpired()
|
||||
|
||||
if result.Err != nil {
|
||||
mlog.Error(result.Err.Error())
|
||||
}
|
||||
|
||||
return result.Err
|
||||
}
|
||||
|
||||
func (a *App) ListPluginKeys(pluginId string, page, perPage int) ([]string, *model.AppError) {
|
||||
result := <-a.Srv.Store.Plugin().List(pluginId, page, perPage)
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user