intrepid_model/caches/cache_record.rs
use bytes::Bytes;
/// A record in a cache. This is designed to represent values in a simple
/// key-value store, and so it has minimal fields. The `uri` field is the
/// key, and the `data` field is the value. An extra `meta` field is included
/// for additional information that may be useful, like timestamps or other
/// bits that might not make sense to store in the `data` field.
///
#[derive(Clone, Debug, Default, PartialEq, Eq)]
pub struct CacheRecord {
/// The URI of the record
pub uri: String,
/// The main data of the record
pub data: Bytes,
/// Any additional metadata
pub meta: Bytes,
}
impl CacheRecord {
/// Create a new cache record
pub fn new(uri: impl Into<String>, data: impl Into<Bytes>) -> Self {
Self {
uri: uri.into(),
data: data.into(),
..Default::default()
}
}
}