mirror of
https://github.com/luxfi/vm.git
synced 2026-10-30 15:13:40 +00:00
35 lines
699 B
Go
35 lines
699 B
Go
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package admin
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/luxfi/database"
|
|
)
|
|
|
|
var _ database.KeyValueReader = (*KeyValueReader)(nil)
|
|
|
|
type KeyValueReader struct {
|
|
client *Client
|
|
}
|
|
|
|
func NewKeyValueReader(client *Client) *KeyValueReader {
|
|
return &KeyValueReader{
|
|
client: client,
|
|
}
|
|
}
|
|
|
|
func (r *KeyValueReader) Has(key []byte) (bool, error) {
|
|
_, err := r.client.DBGet(context.Background(), key)
|
|
if err == database.ErrNotFound {
|
|
return false, nil
|
|
}
|
|
return err == nil, err
|
|
}
|
|
|
|
func (r *KeyValueReader) Get(key []byte) ([]byte, error) {
|
|
return r.client.DBGet(context.Background(), key)
|
|
}
|