hotpotatoc / kvstore Goto Github PK
View Code? Open in Web Editor NEW🗄️kvstore is an experimental in-memory database server compatible with the redis protocol (RESP).
License: MIT License
🗄️kvstore is an experimental in-memory database server compatible with the redis protocol (RESP).
License: MIT License
Add command flags for the kvstore cli and kvstore server
Have yet to implement an iterator for list
127.0.0.1:7275> set user::1 juan
0.000368s
OK
127.0.0.1:7275> get user::1
0.000304s
"juan"
127.0.0.1:7275> list
0.000316s
1) [0]: "%!s(*hashtable.Bucket=<nil>)"
2) [1]: "%!s(*hashtable.Bucket=<nil>)"
3) [2]: "%!s(*hashtable.Bucket=<nil>)"
4) [3]: "%!s(*hashtable.Bucket=<nil>)"
5) [4]: "%!s(*hashtable.Bucket=<nil>)"
6) [5]: "&{%!s(*hashtable.Entry=&{user::1 juan <nil>})}"
7) [6]: "%!s(*hashtable.Bucket=<nil>)"
8) [7]: "%!s(*hashtable.Bucket=<nil>)"
9) [8]: "%!s(*hashtable.Bucket=<nil>)"
10) [9]: "%!s(*hashtable.Bucket=<nil>)"
11) [10]: "%!s(*hashtable.Bucket=<nil>)"
12) [11]: "%!s(*hashtable.Bucket=<nil>)"
13) [12]: "&{%!s(*hashtable.Entry=&{a a <nil>})}"
14) [13]: "%!s(*hashtable.Bucket=<nil>)"
15) [14]: "%!s(*hashtable.Bucket=<nil>)"
16) [15]: "%!s(*hashtable.Bucket=<nil>)"
127.0.0.1:7275> list
0.000316s
1) [user::1]: "juan"
2) [a]: "a"
Running the set
command does not replace an already existing key. instead, it's creating a new entry with the same key. Resulting in a duplicate entry.
user::1 -> john
user::1 -> john
user::1 -> richard
When using a capitalized command like GET
instead of get
it returns <nil>
127.0.0.1:7275> set person john
0.000293s
127.0.0.1:7275> get person
0.000353s
john
127.0.0.1:7275> GET person
0.000326s
<nil>```
Running the list
command only displays a single data
127.0.0.1:7275> set a a
0.000559s
OK
127.0.0.1:7275> set b b
0.000374s
OK
127.0.0.1:7275> list
0.000393s
1) [3826002220]: "a"
expected
127.0.0.1:7275> list
1) [3826002220]: "a"
2) [some_hash_key_idx]: "b"
Inserted entries with the key "a"-"z" with its respective values.
127.0.0.1:7275> list
0.000670s
1) [0]: "&{%!s(*hashtable.Entry=&{u u <nil>})}"
2) [1]: "&{%!s(*hashtable.Entry=&{n n <nil>})}"
3) [2]: "&{%!s(*hashtable.Entry=&{s s <nil>})}"
4) [3]: "&{%!s(*hashtable.Entry=&{t t <nil>})}"
5) [4]: "&{%!s(*hashtable.Entry=&{y y <nil>})}"
6) [5]: "&{%!s(*hashtable.Entry=&{r r <nil>})}"
7) [6]: "&{%!s(*hashtable.Entry=&{w w <nil>})}"
8) [7]: "&{%!s(*hashtable.Entry=&{x x <nil>})}"
9) [8]: "&{%!s(*hashtable.Entry=&{m m <nil>})}"
10) [9]: "&{%!s(*hashtable.Entry=&{v v <nil>})}"
11) [10]: "&{%!s(*hashtable.Entry=&{k k <nil>})}"
12) [11]: "&{%!s(*hashtable.Entry=&{l l <nil>})}"
13) [12]: "&{%!s(*hashtable.Entry=&{q q <nil>})}"
14) [13]: "&{%!s(*hashtable.Entry=&{z z <nil>})}"
15) [14]: "&{%!s(*hashtable.Entry=&{o o <nil>})}"
16) [15]: "&{%!s(*hashtable.Entry=&{p p <nil>})}"
26 records but got the default size of 16
A Runtime error occurred when trying to set an entry with the same key as the former
CLI
127.0.0.1:7275> set key value
OK
127.0.0.1:7275> list
1 items
key -> "value"
127.0.0.1:7275> del key
1
127.0.0.1:7275> set key value
SERVER
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x68e891]
goroutine 8 [running]:
github.com/HotPotatoC/kvstore/pkg/hashtable.(*HashTable).insert(0xc00002aa00, 0xc000016ce0, 0x3, 0xc000016ce4, 0x5, 0x0)
/home/juanchristian/go/src/github.com/HotPotatoC/kvstore/pkg/hashtable/hash_table.go:183 +0x1b1
github.com/HotPotatoC/kvstore/pkg/hashtable.(*HashTable).Set(0xc00002aa00, 0xc000016ce0, 0x3, 0xc000016ce4, 0x5)
/home/juanchristian/go/src/github.com/HotPotatoC/kvstore/pkg/hashtable/hash_table.go:61 +0xb0
github.com/HotPotatoC/kvstore/database.(*database).Set(0xc0000100b0, 0xc000016ce0, 0x3, 0xc000016ce4, 0x5)
/home/juanchristian/go/src/github.com/HotPotatoC/kvstore/database/database.go:46 +0x56
github.com/HotPotatoC/kvstore/command.setCommand.Execute(0x7e71d0, 0xc0000100b0, 0xc000062660, 0x2, 0x2, 0x1, 0x2, 0xc000062660)
/home/juanchristian/go/src/github.com/HotPotatoC/kvstore/command/set_command.go:35 +0x118
github.com/HotPotatoC/kvstore/server.(*Server).onMessage(0xc00007d590, 0x7e7280, 0xc0000100c8, 0xc000200000, 0x9000, 0x9000)
/home/juanchristian/go/src/github.com/HotPotatoC/kvstore/server/hooks.go:49 +0x3ac
github.com/HotPotatoC/kvstore/pkg/tcp.(*Server).handleConnection(0xc00007d620, 0x7e7280, 0xc0000100c8)
/home/juanchristian/go/src/github.com/HotPotatoC/kvstore/pkg/tcp/tcp.go:90 +0x2c2
github.com/HotPotatoC/kvstore/pkg/tcp.(*Server).acceptConnections.func1(0xc00007d620, 0x7e7280, 0xc0000100c8)
/home/juanchristian/go/src/github.com/HotPotatoC/kvstore/pkg/tcp/tcp.go:62 +0x65
created by github.com/HotPotatoC/kvstore/pkg/tcp.(*Server).acceptConnections
/home/juanchristian/go/src/github.com/HotPotatoC/kvstore/pkg/tcp/tcp.go:60 +0x7a
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.