Skip to content

Commit

Permalink
fixed mget in redis with namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
latolukasz committed Jul 5, 2023
1 parent 86e0da1 commit 7ce3378
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 14 deletions.
14 changes: 0 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,13 @@ require (
)

require (
github.com/BurntSushi/toml v1.3.2 // indirect
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/chavacava/garif v0.0.0-20230608123814-4bd63c2919ab // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/fatih/color v1.15.0 // indirect
github.com/fatih/structtag v1.2.0 // indirect
github.com/kr/pretty v0.1.0 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.19 // indirect
github.com/mattn/go-runewidth v0.0.14 // indirect
github.com/mgechev/dots v0.0.0-20210922191527-e955255bf517 // indirect
github.com/mgechev/revive v1.3.2 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/olekukonko/tablewriter v0.0.5 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.4 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/tools v0.9.3 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
46 changes: 46 additions & 0 deletions load_by_id_benchmarks_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package beeorm

import (
"testing"
)

type loadByIDBenchmarkEntity struct {
ORM `orm:"localCache;redisCache"`
ID uint
Name string
Int int
Bool bool
Float float64
Decimal float32 `orm:"decimal=10,2"`
}

// BenchmarkLoadByIDLocalCache-10 3572815 325.6 ns/op 152 B/op 6 allocs/op
func BenchmarkLoadByIDLocalCache(b *testing.B) {
benchmarkLoadByIDCache(b, true, false)
}

// BenchmarkLoadByIDRedisCache-10 1695 603416 ns/op 421 B/op 15 allocs/op
func BenchmarkLoadByIDRedisCache(b *testing.B) {
benchmarkLoadByIDCache(b, false, true)
}

func benchmarkLoadByIDCache(b *testing.B, local, redis bool) {
entity := &loadByIDBenchmarkEntity{}
registry := &Registry{}
registry.RegisterLocalCache(10000)
engine := PrepareTables(nil, registry, 5, 6, "", entity)
schema := engine.GetRegistry().GetEntitySchemaForEntity(entity).(*entitySchema)
schema.DisableCache(!local, !redis)

entity.Name = "Name"
entity.Int = 1
entity.Float = 1.3
entity.Decimal = 12.23
engine.Flush(entity)
_ = engine.LoadByID(1, entity)
b.ResetTimer()
b.ReportAllocs()
for n := 0; n < b.N; n++ {
_ = engine.LoadByID(1, entity)
}
}

0 comments on commit 7ce3378

Please sign in to comment.