Functionin corecompute-sdk-go v1.11.0View source
func Lookup(key []byte, opts LookupOptions) (*Found, error)

Lookup performs a simple, non-transactional lookup for the given key. If the key is not cached, [ErrNotFound] is returned. Keys can be up to 4096 bytes in length.

In contrast to lookups using NewTransaction, this will not coordinate with any concurrent cache lookups. No request collapsing is done.

Parameters

key: []byte
opts: LookupOptions

Returns

(*Found, error)
1
2
3
4
5
6
7
8
9
10
11
12
f, err := core.Lookup([]byte("my_key"), core.LookupOptions{})
if err != nil {
panic(err)
}
defer f.Body.Close()
cachedStr, err := io.ReadAll(f.Body)
if err != nil {
panic(err)
}
fmt.Printf("The cached value was: %s", cachedStr)