pub struct CacheKey(/* private fields */);Expand description
A cache key.
Implementations§
Source§impl CacheKey
impl CacheKey
Sourcepub fn builder() -> CacheKeyBuilder
pub fn builder() -> CacheKeyBuilder
Creates a cache key builder.
Examples found in repository?
examples/basic_usage.rs (line 14)
6fn main() -> Result<(), Box<dyn std::error::Error>> {
7 let collection = CollectionName::new("customers");
8 let document_id = DocumentId::new("customer_123");
9 let patch = PatchSet::new(vec![PatchOperation::set(
10 DocumentPath::new("profile.display_name"),
11 "Joshua Whalen",
12 )]);
13
14 let key = CacheKey::builder()
15 .namespace(CacheNamespace::new("reviews"))
16 .segment("google-business-profile")
17 .segment("location")
18 .segment("fort-wayne")
19 .segment("summary")
20 .build();
21
22 let record = VectorRecord::new(
23 VectorId::new("review_789_embedding"),
24 Embedding::new(vec![0.012, -0.032, 0.481]),
25 )
26 .with_dimension(VectorDimension::new(3))?
27 .with_similarity_metric(SimilarityMetric::Cosine);
28
29 assert_eq!(collection.as_str(), "customers");
30 assert_eq!(document_id.as_str(), "customer_123");
31 assert_eq!(patch.operations().len(), 1);
32 assert_eq!(
33 key.to_string(),
34 "reviews:google-business-profile:location:fort-wayne:summary"
35 );
36 assert_eq!(record.dimension(), Some(VectorDimension::new(3)));
37
38 Ok(())
39}Trait Implementations§
Source§impl Ord for CacheKey
impl Ord for CacheKey
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for CacheKey
impl PartialOrd for CacheKey
impl Eq for CacheKey
impl StructuralPartialEq for CacheKey
Auto Trait Implementations§
impl Freeze for CacheKey
impl RefUnwindSafe for CacheKey
impl Send for CacheKey
impl Sync for CacheKey
impl Unpin for CacheKey
impl UnsafeUnpin for CacheKey
impl UnwindSafe for CacheKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more