Skip to content

Commit

Permalink
[Chore] Add clockpro
Browse files Browse the repository at this point in the history
  • Loading branch information
maypok86 committed Feb 25, 2024
1 parent 11e1e89 commit f002f21
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 0 deletions.
37 changes: 37 additions & 0 deletions client/clockpro.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package client

import (
"strconv"

"github.com/dgryski/go-clockpro"
)

type ClockPro struct {
client *clockpro.Cache
}

func (c *ClockPro) Init(capacity int) {
client := clockpro.New(capacity)
c.client = client
}

func (c *ClockPro) Name() string {
return "clockpro"
}

func (c *ClockPro) Get(key uint64) (uint64, bool) {
v := c.client.Get(strconv.FormatUint(key, 10))
if v == nil {
return 0, false
}

return v.(uint64), true
}

func (c *ClockPro) Set(key, value uint64) {
c.client.Set(strconv.FormatUint(key, 10), value)
}

func (c *ClockPro) Close() {
c.client = nil
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ require (
github.com/BurntSushi/toml v1.3.2
github.com/Yiling-J/theine-go v0.3.2
github.com/dgraph-io/ristretto v0.1.1
github.com/dgryski/go-clockpro v0.0.0-20140817124034-edc6d3eeb96e
github.com/dgryski/go-tinylfu v0.0.0-20230408121034-c8e5d79bbb04
github.com/go-echarts/go-echarts/v2 v2.4.0-rc1.0.20240207165231-c682d25c82b8
github.com/go-echarts/snapshot-chromedp v0.0.1
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8=
github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA=
github.com/dgryski/go-clockpro v0.0.0-20140817124034-edc6d3eeb96e h1:kXrIYQccdty+/6teoePZ5ZzF8yu+EivWFhs5HvFlVR8=
github.com/dgryski/go-clockpro v0.0.0-20140817124034-edc6d3eeb96e/go.mod h1:XOXaSpwU7uEii1eX5P3U3Me/TInU6t/JljfWLex+FIw=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/dgryski/go-tinylfu v0.0.0-20230408121034-c8e5d79bbb04 h1:KfJuUjcn6CWRMluEAcZb/zqhml0P6rsxAHtSTetvqQ8=
Expand Down
1 change: 1 addition & 0 deletions simulator/internal/simulator/simulator.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func getClients() map[string]client.Client[uint64, uint64] {
&client.Otter[uint64, uint64]{},
&client.Theine[uint64, uint64]{},
&client.TinyLFU{},
&client.ClockPro{},
&client.Ristretto[uint64, uint64]{},
&client.LRU[uint64, uint64]{},
&client.ARC[uint64, uint64]{},
Expand Down

0 comments on commit f002f21

Please sign in to comment.