Squashed commit of the following:

commit 05d142664d
Author: Mohamed Sohail 天明 <sohailsameja@gmail.com>
Date:   Mon Oct 7 15:12:58 2024 +0300

    feat: handle contract creation (#43)

    * feat: add contract creation handler

    * fix: process contract creations

    * fix: redis keys name

commit 4b2ad3daf9
Author: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Date:   Mon Oct 7 15:12:15 2024 +0300

    build(deps): bump github.com/knadh/koanf/providers/env (#37)

    Bumps [github.com/knadh/koanf/providers/env](https://github.com/knadh/koanf) from 0.1.0 to 1.0.0.
    - [Release notes](https://github.com/knadh/koanf/releases)
    - [Commits](https://github.com/knadh/koanf/compare/v0.1.0...v1.0.0)

    ---
    updated-dependencies:
    - dependency-name: github.com/knadh/koanf/providers/env
      dependency-type: direct:production
      update-type: version-update:semver-major
    ...

    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

commit f1086fcdc1
Author: Mohamed Sohail 天明 <sohailsameja@gmail.com>
Date:   Mon Oct 7 10:07:11 2024 +0300

    feat: optimize exists to check multiple keys in one call (#40)

    * closes #32

commit fd59d286f5
Author: Mohammed Sohail <sohailsameja@gmail.com>
Date:   Mon Oct 7 09:49:01 2024 +0300

    feat: add custodial registration proxy handler
This commit is contained in:
2024-10-07 15:14:24 +03:00
parent 8e3e027044
commit 725c18c0ff
12 changed files with 206 additions and 30 deletions

View File

@@ -9,7 +9,7 @@ type (
Cache interface {
Add(context.Context, string) error
Remove(context.Context, string) error
Exists(context.Context, string) (bool, error)
Exists(context.Context, ...string) (bool, error)
Size(context.Context) (int64, error)
}

View File

@@ -40,8 +40,8 @@ func (c *redisCache) Remove(ctx context.Context, key string) error {
return c.client.Do(ctx, cmd).Error()
}
func (c *redisCache) Exists(ctx context.Context, key string) (bool, error) {
cmd := c.client.B().Exists().Key(key).Build()
func (c *redisCache) Exists(ctx context.Context, keys ...string) (bool, error) {
cmd := c.client.B().Exists().Key(keys...).Build()
res, err := c.client.Do(ctx, cmd).AsBool()
if err != nil {
return false, err

View File

@@ -26,9 +26,14 @@ func (c *mapCache) Remove(_ context.Context, key string) error {
return nil
}
func (c *mapCache) Exists(_ context.Context, key string) (bool, error) {
_, ok := c.xmap.Load(key)
return ok, nil
func (c *mapCache) Exists(_ context.Context, key ...string) (bool, error) {
for _, v := range key {
_, ok := c.xmap.Load(v)
if ok {
return true, nil
}
}
return false, nil
}
func (c *mapCache) Size(_ context.Context) (int64, error) {