mirror of
https://github.com/eosswedenorg/thalos
synced 2026-07-03 11:53:41 +02:00
move internal/abi_cache to abi
This commit is contained in:
parent
c05b789269
commit
92c605c7fa
3 changed files with 7 additions and 8 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
package abi_cache
|
package abi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
|
|
@ -14,7 +14,7 @@ type Cache struct {
|
||||||
prefix string
|
prefix string
|
||||||
}
|
}
|
||||||
|
|
||||||
func New(prefix string, options *redis_cache.Options) *Cache {
|
func NewCache(prefix string, options *redis_cache.Options) *Cache {
|
||||||
return &Cache{
|
return &Cache{
|
||||||
c: redis_cache.New(options),
|
c: redis_cache.New(options),
|
||||||
ctx: context.Background(),
|
ctx: context.Background(),
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
package abi_cache
|
package abi
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
@ -73,7 +73,7 @@ var abiString = `
|
||||||
`
|
`
|
||||||
|
|
||||||
func TestGetSet(t *testing.T) {
|
func TestGetSet(t *testing.T) {
|
||||||
c := New("abi.cache.test", &redis_cache.Options{
|
c := NewCache("abi.cache.test", &redis_cache.Options{
|
||||||
Redis: redis.NewClient(&redis.Options{}),
|
Redis: redis.NewClient(&redis.Options{}),
|
||||||
// Cache 10k keys for 1 minute.
|
// Cache 10k keys for 1 minute.
|
||||||
LocalCache: redis_cache.NewTinyLFU(10000, time.Minute),
|
LocalCache: redis_cache.NewTinyLFU(10000, time.Minute),
|
||||||
|
|
@ -139,7 +139,7 @@ func TestGetSet(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestCacheMiss(t *testing.T) {
|
func TestCacheMiss(t *testing.T) {
|
||||||
c := New("abi.cache.test", &redis_cache.Options{
|
c := NewCache("abi.cache.test", &redis_cache.Options{
|
||||||
Redis: redis.NewClient(&redis.Options{}),
|
Redis: redis.NewClient(&redis.Options{}),
|
||||||
// Cache 10k keys for 1 minute.
|
// Cache 10k keys for 1 minute.
|
||||||
LocalCache: redis_cache.NewTinyLFU(10000, time.Minute),
|
LocalCache: redis_cache.NewTinyLFU(10000, time.Minute),
|
||||||
|
|
@ -5,7 +5,6 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"eosio-ship-trace-reader/internal/abi_cache"
|
|
||||||
"eosio-ship-trace-reader/internal/redis"
|
"eosio-ship-trace-reader/internal/redis"
|
||||||
|
|
||||||
eos "github.com/eoscanada/eos-go"
|
eos "github.com/eoscanada/eos-go"
|
||||||
|
|
@ -13,14 +12,14 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type AbiManager struct {
|
type AbiManager struct {
|
||||||
cache *abi_cache.Cache
|
cache *Cache
|
||||||
api *eos.API
|
api *eos.API
|
||||||
ctx context.Context
|
ctx context.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewAbiManager(api *eos.API, id string) *AbiManager {
|
func NewAbiManager(api *eos.API, id string) *AbiManager {
|
||||||
// Init abi cache
|
// Init abi cache
|
||||||
cache := abi_cache.New("ship.cache."+id+".abi", &redis_cache.Options{
|
cache := NewCache("ship.cache."+id+".abi", &redis_cache.Options{
|
||||||
Redis: redis.Client(),
|
Redis: redis.Client(),
|
||||||
// Cache 10k keys for 10 minutes.
|
// Cache 10k keys for 10 minutes.
|
||||||
LocalCache: redis_cache.NewTinyLFU(10000, 10*time.Minute),
|
LocalCache: redis_cache.NewTinyLFU(10000, 10*time.Minute),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue