mirror of
https://github.com/hanzokv/mock.git
synced 2026-10-30 19:45:21 +00:00
github.com/hanzokv/go/v9 v9.22.0 renamed its Go package from "redis" to "kv"; the import path is unchanged. A mock library is typed against the client it wraps, so this is not cosmetic: every exported signature in this package (ClientMock, ClusterClientMock, all Expect* methods) is expressed in terms of the client's types, and none of them resolve under the old qualifier. What changed: - go.mod: github.com/hanzokv/go/v9 v9.21.1 -> v9.22.0 - every "redis." qualifier -> "kv." The import stays unaliased, matching the convention in hanzokv/go's own sources. - package redismock -> package kvmock, matching the hanzokv/mock repo - our own vocabulary follows the client it mocks: RedisNil() -> KVNil(), isRedisNil/redisNil -> isKVNil/kvNil, redisClientType -> kvClientType, redisClient/redisCluster -> kvClient/kvCluster, redisClientHook -> kvClientHook, TestRedisMock -> TestKVMock - comments and README speak kv - gofmt: import blocks in the ginkgo test files were left unsorted by the fork commit; formatting them is a side effect of touching them Opaque test payloads are left alone -- they are data, not vocabulary. Verified: go build ./..., go vet ./..., go test ./..., and go test ./... -short -race all pass. Co-authored-by: Hanzo Dev <[email protected]>
23 lines
371 B
Go
23 lines
371 B
Go
package ordinary
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/hanzokv/go/v9"
|
|
)
|
|
|
|
const itemKey = "item_cache"
|
|
|
|
var ctx = context.TODO()
|
|
|
|
func ItemCache(db *kv.Client, itemID string) (item string, err error) {
|
|
item, err = db.HGet(ctx, itemKey, itemID).Result()
|
|
if err == kv.Nil {
|
|
// call api
|
|
item = "information"
|
|
|
|
err = db.HSet(ctx, itemKey, itemID, item).Err()
|
|
}
|
|
return
|
|
}
|