interface key-value {
type value = list<u8>;
/// FastEdge key-value persistent store resource
resource store {
/// Open the store with the specified name.
///
/// `error::no-such-store` will be raised if the `name` is not recognized.
open: static func(name: string) -> result<store, error>;
/// Get the value associated with the specified `key`
///
/// Returns `ok(none)` if the key does not exist.
get: func(key: string) -> result<option<value>, error>;
/// Interface to scan over keys in the store.
/// It matches glob-style pattern filter on each element from the retrieved collection.
///
/// Returns an array of elements as a list of keys.
scan: func(pattern: string) -> result<list<string>, error>;
/// Get all the elements with score from the sorted set at `key` with a f64 score between min and max
/// (including elements with score equal to min or max). The elements are considered to be ordered from low to high
/// scores.
///
/// Returns empty `Vec` if the key does not exist or if no elements have scores between min and max.
zrange-by-score: func(key: string, min: f64, max: f64) -> result<list<tuple<value, f64>>, error>;
/// Interface to scan through a sorted set by key
/// It matches glob-style pattern filter on each elements from the retrieved collection.
///
/// Returns an array of elements as a list of value of the Sorted Set.
zscan: func(key: string, pattern: string) -> result<list<tuple<value, f64>>, error>;
/// Determines whether a given item was added to a Bloom filter.
///
/// Returns one of these replies: 'true' means that, with high probability, item was already added to the filter,
/// and 'false' means that key does not exist or that item had not been added to the filter.
bf-exists: func(key: string, item: string) -> result<bool, error>;
}
/// The set of errors which may be raised by functions in this interface
variant error {
/// The host does not recognize the store label requested.
no-such-store,
/// The requesting component does not have access to the specified store
/// (which may or may not exist).
access-denied,
/// Some unexpected internal error has occurred.
internal-error,
/// Some implementation-specific error has occurred (e.g. I/O)
other(string)
}
}