fast_cache/storage/embedded_store_sharded/
lifecycle.rs1use super::*;
2
3impl WorkerLocalEmbeddedStore {
4 pub fn delete(&mut self, key: &[u8]) -> bool {
5 self.delete_if_local(key)
6 .expect("worker-local embedded store key does not belong to this thread")
7 }
8
9 pub fn delete_if_local(&mut self, key: &[u8]) -> Result<bool, LocalRouteError> {
10 self.local_key_route(key)?;
11 Ok(self.inner.local_delete(key))
12 }
13
14 pub fn exists(&mut self, key: &[u8]) -> bool {
15 self.exists_if_local(key)
16 .expect("worker-local embedded store key does not belong to this thread")
17 }
18
19 pub fn exists_if_local(&mut self, key: &[u8]) -> Result<bool, LocalRouteError> {
20 self.local_key_route(key)?;
21 Ok(self.inner.local_exists(key))
22 }
23
24 pub fn ttl_seconds(&mut self, key: &[u8]) -> i64 {
25 self.ttl_seconds_if_local(key)
26 .expect("worker-local embedded store key does not belong to this thread")
27 }
28
29 pub fn ttl_seconds_if_local(&mut self, key: &[u8]) -> Result<i64, LocalRouteError> {
30 self.local_key_route(key)?;
31 Ok(self.inner.local_ttl_seconds(key))
32 }
33
34 pub fn pttl_millis(&mut self, key: &[u8]) -> i64 {
35 self.pttl_millis_if_local(key)
36 .expect("worker-local embedded store key does not belong to this thread")
37 }
38
39 pub fn pttl_millis_if_local(&mut self, key: &[u8]) -> Result<i64, LocalRouteError> {
40 self.local_key_route(key)?;
41 Ok(self.inner.local_pttl_millis(key))
42 }
43
44 pub fn expire(&mut self, key: &[u8], expire_at_ms: u64) -> bool {
45 self.expire_if_local(key, expire_at_ms)
46 .expect("worker-local embedded store key does not belong to this thread")
47 }
48
49 pub fn expire_if_local(
50 &mut self,
51 key: &[u8],
52 expire_at_ms: u64,
53 ) -> Result<bool, LocalRouteError> {
54 self.local_key_route(key)?;
55 Ok(self.inner.local_expire(key, expire_at_ms))
56 }
57
58 pub fn persist(&mut self, key: &[u8]) -> bool {
59 self.persist_if_local(key)
60 .expect("worker-local embedded store key does not belong to this thread")
61 }
62
63 pub fn persist_if_local(&mut self, key: &[u8]) -> Result<bool, LocalRouteError> {
64 self.local_key_route(key)?;
65 Ok(self.inner.local_persist(key))
66 }
67
68 pub fn len(&self) -> usize {
69 self.inner.len()
70 }
71
72 pub fn is_empty(&self) -> bool {
73 self.inner.is_empty()
74 }
75
76 pub fn process_maintenance(&mut self) -> usize {
77 self.inner.process_maintenance()
78 }
79
80 pub fn stats_snapshot(&self) -> (TierStatsSnapshot, TierStatsSnapshot, TierStatsSnapshot) {
81 self.inner.local_tier_stats_snapshot()
82 }
83}