-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
35 Added the support for FILTERKEYS #84
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package istorageengines | ||
|
||
import ( | ||
"sync" | ||
|
||
"github.com/dicedb/dice/object" | ||
) | ||
|
||
type IKVStorage interface { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. rename the interface and keep it StorageEngine |
||
Put(key string, obj *object.Obj) | ||
Get(key string) *object.Obj | ||
Del(key string) bool | ||
GetCount() uint64 | ||
GetStorage() *sync.Map | ||
Comment on lines
+13
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's rename it to Count and Storage ... more go-like. and as discussed, the Storage should return an iterator - a function that upon invocation returns the next KV pair. |
||
// GetExpiry() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package istorageengines | ||
|
||
// This is for future usage to use Redis Storage | ||
// as the main storage engine instead of KV | ||
Comment on lines
+1
to
+4
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's remove this file. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,28 +6,31 @@ import ( | |
"os" | ||
"strings" | ||
|
||
dbEngine "github.com/dicedb/dice/IStorageEngines" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dbEngine -> storage_engine |
||
"github.com/dicedb/dice/config" | ||
"github.com/dicedb/dice/object" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. instead of creating another package for object see if we can fit it in |
||
) | ||
|
||
// TODO: Support Expiration | ||
// TODO: Support non-kv data structures | ||
// TODO: Support sync write | ||
func dumpKey(fp *os.File, key string, obj *Obj) { | ||
func dumpKey(fp *os.File, key string, obj *object.Obj) { | ||
cmd := fmt.Sprintf("SET %s %s", key, obj.Value) | ||
tokens := strings.Split(cmd, " ") | ||
fp.Write(Encode(tokens, false)) | ||
} | ||
|
||
// TODO: To to new and switch | ||
func DumpAllAOF() { | ||
func DumpAllAOF(dh dbEngine.IKVStorage) { | ||
fp, err := os.OpenFile(config.AOFFile, os.O_CREATE|os.O_WRONLY, os.ModeAppend) | ||
if err != nil { | ||
fmt.Print("error", err) | ||
return | ||
} | ||
log.Println("rewriting AOF file at", config.AOFFile) | ||
for k, obj := range store { | ||
dumpKey(fp, k, obj) | ||
} | ||
dh.GetStorage().Range(func(k, v interface{}) bool { | ||
dumpKey(fp, k.(string), v.(*object.Obj)) | ||
return true | ||
}) | ||
log.Println("AOF file rewrite complete") | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,8 @@ import ( | |
"fmt" | ||
"io" | ||
"syscall" | ||
|
||
"github.com/dicedb/dice/handlers" | ||
) | ||
|
||
type Client struct { | ||
|
@@ -26,13 +28,13 @@ func (c *Client) TxnBegin() { | |
c.isTxn = true | ||
} | ||
|
||
func (c *Client) TxnExec() []byte { | ||
func (c *Client) TxnExec(dh *handlers.DiceKVstoreHandler) []byte { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of calling it handler, let's name our storage engine and use that here. I propose the name - |
||
var out []byte | ||
buf := bytes.NewBuffer(out) | ||
|
||
buf.WriteString(fmt.Sprintf("*%d\r\n", len(c.cqueue))) | ||
for _, _cmd := range c.cqueue { | ||
buf.Write(executeCommand(_cmd, c)) | ||
buf.Write(executeCommand(_cmd, c, dh)) | ||
} | ||
|
||
c.cqueue = make(RedisCmds, 0) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name of the package should be
storage_engines