@@ -48,16 +48,6 @@ type KVOperator struct {
4848 pluginSlugName string
4949}
5050
51- func (kv * KVOperator ) checkDB () error {
52- if kv .data == nil {
53- return ErrKVDataNotInitialized
54- }
55- if kv .data .DB == nil {
56- return ErrKVDBNotInitialized
57- }
58- return nil
59- }
60-
6151func (kv * KVOperator ) getSession (ctx context.Context ) (session * xorm.Session , close func ()) {
6252 if kv .session != nil {
6353 session = kv .session
@@ -88,9 +78,6 @@ func (kv *KVOperator) getCacheKey(group, key string) string {
8878
8979func (kv * KVOperator ) Get (ctx context.Context , group , key string ) (string , error ) {
9080 // validate
91- if err := kv .checkDB (); err != nil {
92- return "" , err
93- }
9481 if key == "" {
9582 return "" , ErrKVKeyEmpty
9683 }
@@ -127,10 +114,6 @@ func (kv *KVOperator) Get(ctx context.Context, group, key string) (string, error
127114}
128115
129116func (kv * KVOperator ) Set (ctx context.Context , group , key , value string ) error {
130- if err := kv .checkDB (); err != nil {
131- return err
132- }
133-
134117 if key == "" {
135118 return ErrKVKeyEmpty
136119 }
@@ -168,10 +151,6 @@ func (kv *KVOperator) Set(ctx context.Context, group, key, value string) error {
168151}
169152
170153func (kv * KVOperator ) Del (ctx context.Context , group , key string ) error {
171- if err := kv .checkDB (); err != nil {
172- return err
173- }
174-
175154 if key == "" && group == "" {
176155 return ErrKVKeyAndGroupEmpty
177156 }
@@ -216,10 +195,6 @@ func (kv *KVOperator) cleanCache(ctx context.Context, group, key string) {
216195}
217196
218197func (kv * KVOperator ) GetByGroup (ctx context.Context , group string , page , pageSize int ) (map [string ]string , error ) {
219- if err := kv .checkDB (); err != nil {
220- return nil , err
221- }
222-
223198 if group == "" {
224199 return nil , ErrKVGroupEmpty
225200 }
@@ -231,10 +206,6 @@ func (kv *KVOperator) GetByGroup(ctx context.Context, group string, page, pageSi
231206 pageSize = 10
232207 }
233208
234- if pageSize > 100 {
235- pageSize = 100
236- }
237-
238209 cacheKey := kv .getCacheKey (group , "" )
239210 if value , exist , err := kv .data .Cache .GetString (ctx , cacheKey ); err == nil && exist {
240211 result := make (map [string ]string )
@@ -271,10 +242,6 @@ func (kv *KVOperator) GetByGroup(ctx context.Context, group string, page, pageSi
271242}
272243
273244func (kv * KVOperator ) Tx (ctx context.Context , fn func (ctx context.Context , kv * KVOperator ) error ) error {
274- if err := kv .checkDB (); err != nil {
275- return fmt .Errorf ("%w: %v" , ErrKVTransactionFailed , err )
276- }
277-
278245 var (
279246 txKv = kv
280247 shouldCommit bool
0 commit comments