https://github.com/justlorain/ezcache
EZCache
https://github.com/justlorain/ezcache
cache consistent-hash go
Last synced: 13 days ago
JSON representation
EZCache
- Host: GitHub
- URL: https://github.com/justlorain/ezcache
- Owner: justlorain
- License: apache-2.0
- Created: 2024-05-08T05:05:52.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-06-23T06:04:55.000Z (about 2 years ago)
- Last Synced: 2025-02-27T06:17:41.673Z (over 1 year ago)
- Topics: cache, consistent-hash, go
- Language: Go
- Homepage:
- Size: 23.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# EZCache
## Install
```shell
go get -u github.com/justlorain/ezcache
```
## Usage
```go
package main
import (
"flag"
"strings"
"github.com/justlorain/ezcache"
)
func main() {
addrs := ParseFlags()
e := ezcache.NewEngine(addrs[0])
e.RegisterNodes(addrs...)
if err := e.Run(); err != nil {
return
}
}
// ParseFlags e.g.
// go run . --addrs=http://localhost:7246,http://localhost:7247,http://localhost:7248
// go run . --addrs=http://localhost:7247,http://localhost:7248,http://localhost:7246
// go run . --addrs=http://localhost:7248,http://localhost:7246,http://localhost:7247
// NOTE: first addr is local node
func ParseFlags() []string {
var addrsFlag string
flag.StringVar(&addrsFlag, "addrs", "", "nodes addresses")
flag.Parse()
return strings.Split(addrsFlag, ",")
}
```
## Configuration
| Option | Default | Description |
|--------------------------|----------------------|-------------------------------------------|
| ` WithBasePath` | `/_ezcache` | Define base path of server |
| ` WithReplicationFactor` | `10` | Define consistent hash replication factor |
| ` WithHashFunc` | `crc32.ChecksumIEEE` | Define hash func used by consistent hash |
## License
EZCache is distributed under the [Apache License 2.0](./LICENSE).