DB Access Layer Merges: GetTablePattern ...#103
DB Access Layer Merges: GetTablePattern ...#103anand-kumar-subramanian merged 1 commit intosonic-net:masterfrom
Conversation
| // Run Lua script [Found = SUCCESS return] | ||
| if d.Opts.IsWriteDisabled && !exists { | ||
|
|
||
| //glog.Info("ExistKeysPattern: B4= ", luaScriptExistsKeysPatterns.Hash()) |
| `) | ||
|
|
||
| // Alternate Lua Script | ||
| // luaScriptExistsKeysPatterns = redis.NewScript(` |
There was a problem hiding this comment.
This part looks redundant to me. If the register in L184 executed, all keys should have registered LUA. Is there any case we may need register for single key?
There was a problem hiding this comment.
It is a comment, to indicate an alternate implementation. I would rather keep it.
|
|
||
| keys = make([]Key, 0, len(tkNv)/2) | ||
| for i, v := range tkNv { | ||
| // glog.Info("GetTablePattern: i: ", i, " v: ", v) |
There was a problem hiding this comment.
If this is not needed, please clean it up.
| return table, err | ||
| } | ||
| } else { | ||
| // glog.Info("GetTablePattern: i: ", i, " v: ", v) |
| if cTable, ok := d.cache.Tables[ts.Name]; ok && cTable.complete { | ||
|
|
||
| // Copy relevent keys of cTable to table, and set keys | ||
| // Be aware of cache poisoning |
There was a problem hiding this comment.
I am curious if the code handles the cache poisoning case.
There was a problem hiding this comment.
Yes, it is handled by the Copy() on L113
| delete(tOrig.patterns, db.key2redis(&ts, Key{Comp: []string{"*"}})) | ||
|
|
||
| if !reflect.DeepEqual(tPat, tOrig) { | ||
| fmt.Println("\ntPat: \n", tPat) |
| } | ||
|
|
||
| if !reflect.DeepEqual(tPat, tOrig) { | ||
| fmt.Println("\ntPat: \n", tPat) |
There was a problem hiding this comment.
Same. Suggest to replace fmt.Println() to t.Logf()
There was a problem hiding this comment.
A review has been raised for fixing the issues raised in the review comments:
#106
Added the following APIs: ExistKeysPattern() GetTablePattern() Key.IsAllKeyPattern() Go UT, and Benchmark Tests for the same TranslibDBScriptFail error type to translib/tlerr package
Added the following APIs:
ExistKeysPattern()
GetTablePattern()
Key.IsAllKeyPattern()
Go UT, and Benchmark Tests for the same
TranslibDBScriptFail error type to translib/tlerr package