Skip to content

Commit

Permalink
Use hashmap in bbolt
Browse files Browse the repository at this point in the history
  • Loading branch information
Wikidepia committed Jul 19, 2024
1 parent 79b1f73 commit 5ade353
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 6 additions & 1 deletion handlers/scraper/cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ func hashStringXXHASH(s string) uint32 {
}

func InitDB() {
db, err := bolt.Open("cache.db", 0600, nil)
var boltOptions = &bolt.Options{
Timeout: 0,
NoGrowSync: false,
FreelistType: bolt.FreelistMapType,
}
db, err := bolt.Open("cache.db", 0600, boltOptions)
if err != nil {
panic(err)
}
Expand Down
1 change: 0 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@ func evictCache() {
}
c := ttlBucket.Cursor()
for k, v := c.First(); k != nil; k, v = c.Next() {
println(utils.B2S(k))
if n, err := strconv.ParseInt(utils.B2S(k), 10, 64); err == nil {
if n < curTime {
ttlBucket.Delete(k)
Expand Down

0 comments on commit 5ade353

Please sign in to comment.