Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/techraed/shmedis
redis on minimals
https://github.com/techraed/shmedis
Last synced: 7 days ago
JSON representation
redis on minimals
- Host: GitHub
- URL: https://github.com/techraed/shmedis
- Owner: techraed
- Created: 2020-03-02T21:05:32.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-03-07T16:47:13.000Z (over 4 years ago)
- Last Synced: 2024-06-20T15:17:34.397Z (5 months ago)
- Language: Go
- Size: 14.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# shmedis - redis on minimals
Actually it's a for fun implementation of memcache service. Don't take this seriously.## Features:
1. TCP connection between client and server;
2. "GET", "SET", "REMOVE", "CLOSE", "KEYS" operators;
3. TTL for keys;## Use
server_example.go
```go
package mainimport (
"github.com/SabaunT/shmedis/shmedis_sevice"
"time"
)func main() {
// port
address := "8080"// each 3 seconds server will run cache cleaner
cleanerInterval, _ := time.ParseDuration("3s")// TTL for each key
expirationDuration, _ := time.ParseDuration("3s")
shmedis_sevice.UpServer(address, cleanerInterval, expirationDuration)
}
```client_example.go
```go
package mainimport (
"fmt"
"github.com/SabaunT/shmedis/shmedis_sevice"
)func main() {
// port at which server is
address := "8080"
a := shmedis_sevice.Client(address)// "SET"
a.Set("1", 123)// "GET"
k := a.Get("1")
fmt.Println("client got value", k.DataValue) // 123
// "KEYS"
fmt.Println("keys", a.Keys()) // [1]
// "REMOVE"
a.RemoveKey("1")
fmt.Println("keys", a.Keys()) // []
b := a.Get("1")
fmt.Println("got", b.DataValue) // nila.Close() // Connection to memecache server is closed.
}
```