mirror of
https://github.com/eosswedenorg/thalos
synced 2026-06-17 04:30:03 +02:00
Formatting fix.
This commit is contained in:
parent
953113b456
commit
1e2dda54c8
9 changed files with 440 additions and 448 deletions
|
|
@ -1,42 +1,42 @@
|
|||
|
||||
package abi_cache
|
||||
|
||||
import (
|
||||
"time"
|
||||
"context"
|
||||
redis_cache "github.com/go-redis/cache/v8"
|
||||
eos "github.com/eoscanada/eos-go"
|
||||
"context"
|
||||
"time"
|
||||
|
||||
eos "github.com/eoscanada/eos-go"
|
||||
redis_cache "github.com/go-redis/cache/v8"
|
||||
)
|
||||
|
||||
type Cache struct {
|
||||
c *redis_cache.Cache
|
||||
ctx context.Context
|
||||
prefix string
|
||||
c *redis_cache.Cache
|
||||
ctx context.Context
|
||||
prefix string
|
||||
}
|
||||
|
||||
func New(prefix string, options *redis_cache.Options) (*Cache) {
|
||||
return &Cache{
|
||||
c: redis_cache.New(options),
|
||||
ctx: context.Background(),
|
||||
prefix: prefix,
|
||||
}
|
||||
func New(prefix string, options *redis_cache.Options) *Cache {
|
||||
return &Cache{
|
||||
c: redis_cache.New(options),
|
||||
ctx: context.Background(),
|
||||
prefix: prefix,
|
||||
}
|
||||
}
|
||||
|
||||
func (this *Cache) Get(account string) (*eos.ABI, error) {
|
||||
var v eos.ABI
|
||||
err := this.c.Get(this.ctx, this.key(account), &v);
|
||||
return &v, err
|
||||
var v eos.ABI
|
||||
err := this.c.Get(this.ctx, this.key(account), &v)
|
||||
return &v, err
|
||||
}
|
||||
|
||||
func (this *Cache) Set(account string, abi *eos.ABI, ttl time.Duration) error {
|
||||
return this.c.Set(&redis_cache.Item{
|
||||
Ctx: this.ctx,
|
||||
Key: this.key(account),
|
||||
Value: *abi,
|
||||
TTL: ttl,
|
||||
})
|
||||
return this.c.Set(&redis_cache.Item{
|
||||
Ctx: this.ctx,
|
||||
Key: this.key(account),
|
||||
Value: *abi,
|
||||
TTL: ttl,
|
||||
})
|
||||
}
|
||||
|
||||
func (this *Cache) key(account string) (string) {
|
||||
return this.prefix + "." + account
|
||||
func (this *Cache) key(account string) string {
|
||||
return this.prefix + "." + account
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue