Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1010 from fqutishat/1003
Browse files Browse the repository at this point in the history
fix: golangci failing for doc/verifiable
  • Loading branch information
fqutishat authored Dec 20, 2019
2 parents ae79892 + 1f8f9b6 commit 1674d60
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 10 deletions.
23 changes: 23 additions & 0 deletions pkg/doc/verifiable/cache.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// +build !js,!wasm

/*
Copyright SecureKey Technologies Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package verifiable

import (
"time"

"github.com/VictoriaMetrics/fastcache"
)

// NewExpirableSchemaCache creates new instance of ExpirableSchemaCache.
func NewExpirableSchemaCache(size int, expiration time.Duration) *ExpirableSchemaCache {
return &ExpirableSchemaCache{
cache: fastcache.New(size),
expiration: expiration,
}
}
18 changes: 18 additions & 0 deletions pkg/doc/verifiable/cache_js_wasm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
Copyright SecureKey Technologies Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/

package verifiable

import "time"

// NewExpirableSchemaCache creates new instance of ExpirableSchemaCache.
func NewExpirableSchemaCache(size int, expiration time.Duration) *ExpirableSchemaCache {
// TODO Add cache implementation for VC wasm https://github.com/hyperledger/aries-framework-go/issues/1009
return &ExpirableSchemaCache{
cache: nil,
expiration: expiration,
}
}
20 changes: 10 additions & 10 deletions pkg/doc/verifiable/credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"net/http"
"time"

"github.com/VictoriaMetrics/fastcache"
"github.com/xeipuuv/gojsonschema"

"github.com/hyperledger/aries-framework-go/pkg/common/log"
Expand Down Expand Up @@ -223,20 +222,21 @@ type SchemaCache interface {
Get(k string) ([]byte, bool)
}

// cache defines a cache interface
type cache interface {
Set(k, v []byte)

HasGet(dst, k []byte) ([]byte, bool)

Del(k []byte)
}

// ExpirableSchemaCache is an implementation of SchemaCache based fastcache.Cache with expirable elements.
type ExpirableSchemaCache struct {
cache *fastcache.Cache
cache cache
expiration time.Duration
}

// NewExpirableSchemaCache creates new instance of ExpirableSchemaCache.
func NewExpirableSchemaCache(size int, expiration time.Duration) *ExpirableSchemaCache {
return &ExpirableSchemaCache{
cache: fastcache.New(size),
expiration: expiration,
}
}

// CredentialSchemaLoader defines expirable cache.
type CredentialSchemaLoader struct {
schemaDownloadClient *http.Client
Expand Down

0 comments on commit 1674d60

Please sign in to comment.