Skip to main content

CachedDeviceStore

Struct CachedDeviceStore 

Source
pub struct CachedDeviceStore<S>
where S: DeviceStore,
{ /* private fields */ }
Available on crate feature device only.
Expand description

In-process cache decorator wrapping any DeviceStore.

Construct with CachedDeviceStore::new for default settings, or build via with_capacity / with_ttl / with_clock.

Implementations§

Source§

impl<S> CachedDeviceStore<S>
where S: DeviceStore,

Source

pub fn new(inner: S) -> Self

Wrap inner with default cache settings (10k entries, 60 s TTL, SystemClock).

Source

pub fn with_options( inner: S, capacity: usize, ttl: Duration, clock: Arc<dyn Clock>, ) -> Self

Construct with explicit cache parameters.

Source

pub fn with_capacity(self, capacity: usize) -> Self

Builder: override the cache capacity (default 10,000).

Source

pub fn with_ttl(self, ttl: Duration) -> Self

Builder: override the cache TTL (default 60 s).

Source

pub fn with_clock(self, clock: Arc<dyn Clock>) -> Self

Builder: inject a Clock for deterministic-simulation testing.

Source

pub fn stats(&self) -> CacheStats

Snapshot of the underlying cache counters (axess_cache::CacheStats). Useful for ops dashboards.

Source

pub fn invalidate_all(&self)

Drop every cached entry. Use after bulk operations that the cache wasn’t notified about (e.g. an offline migration).

Source

pub fn invalidate_tenant(&self, tenant_id: &TenantId)

Drop every cached entry for a given tenant. Useful after a tenant-wide trust-policy change.

Trait Implementations§

Source§

impl<S> Clone for CachedDeviceStore<S>
where S: DeviceStore,

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<S> DeviceStore for CachedDeviceStore<S>
where S: DeviceStore,

Source§

type Error = <S as DeviceStore>::Error

The error type returned by storage operations.
Source§

fn load( &self, tenant_id: &TenantId, id: &DeviceId, ) -> impl Future<Output = Result<Option<Device>, Self::Error>> + Send

Load the device by id. Returns None if absent.
Source§

fn find_by_fingerprint( &self, tenant_id: &TenantId, hash: &FingerprintHash, ) -> impl Future<Output = Result<Option<Device>, Self::Error>> + Send

Look up a device by its keyed fingerprint within a tenant. Used as the fast-path during request handling when no device_id cookie is present yet. Collisions must be vanishingly rare given a per-tenant HMAC key, but implementations MUST scope the query by tenant_id to prevent cross-tenant correlation.
Source§

fn find_for_user( &self, tenant_id: &TenantId, user_id: &UserId, limit: usize, ) -> impl Future<Output = Result<Vec<Device>, Self::Error>> + Send

List active devices for a user, newest-sighted first. limit caps the result so a high-cardinality user doesn’t blow up device-management UIs. Read more
Source§

fn find_by_refresh_family( &self, tenant_id: &TenantId, family_id: &str, ) -> impl Future<Output = Result<Vec<Device>, Self::Error>> + Send

Find every device in tenant carrying a DeviceBinding::Refresh { family_id } matching the supplied family_id. Used by the refresh-cascade path to convert “this refresh-token family was compromised” into the list of Devices to revoke. Read more
Source§

fn save( &self, device: &Device, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Persist a new device row, or overwrite an existing one. Idempotent.
Source§

fn record_sighting( &self, tenant_id: &TenantId, id: &DeviceId, now: DateTime<Utc>, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Touch the last_seen_at timestamp for the given device. Implementations SHOULD perform this as a single UPDATE rather than a load-modify-save round trip.
Source§

fn set_trust_level( &self, tenant_id: &TenantId, id: &DeviceId, level: DeviceTrustLevel, now: DateTime<Utc>, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Set the trust level. Drives transitions across the DeviceTrustLevel ladder. Setting to DeviceTrustLevel::Revoked also stamps revoked_at = now.
Source§

fn delete( &self, tenant_id: &TenantId, id: &DeviceId, ) -> impl Future<Output = Result<(), Self::Error>> + Send

Hard-delete the row. Idempotent. Used by the retention sweep once a Revoked device has aged out of the configured grace window, and by Art 17 erasure cascades.
Source§

fn sweep( &self, tenant_id: &TenantId, now: DateTime<Utc>, ) -> impl Future<Output = Result<SweepCounts, Self::Error>> + Send

Drive the three-stage retention ladder: Trusted → Seen (after the configured Trusted-idle window), Seen → Revoked (after the configured Seen-idle window), Revoked → purged (after the configured grace window). Returns the count of rows changed at each stage. Read more
Source§

fn find_active_for_user( &self, tenant_id: &TenantId, user_id: &UserId, limit: usize, ) -> impl Future<Output = Result<Vec<Device>, Self::Error>> + Send

Same as find_for_user but excludes Revoked rows. Default implementation filters in-memory after a full find_for_user call; SQL backends SHOULD override with a WHERE trust_level != 'Revoked' clause that the optimiser can use against the trust-level index.

Auto Trait Implementations§

§

impl<S> Freeze for CachedDeviceStore<S>
where S: Freeze,

§

impl<S> !RefUnwindSafe for CachedDeviceStore<S>

§

impl<S> Send for CachedDeviceStore<S>

§

impl<S> Sync for CachedDeviceStore<S>

§

impl<S> Unpin for CachedDeviceStore<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for CachedDeviceStore<S>
where S: UnsafeUnpin,

§

impl<S> !UnwindSafe for CachedDeviceStore<S>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> ArchivePointee for T

Source§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
Source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> LayoutRaw for T

Source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Returns the layout of the type.
Source§

impl<T, N1, N2> Niching<NichedOption<T, N1>> for N2
where T: SharedNiching<N1, N2>, N1: Niching<T>, N2: Niching<T>,

Source§

unsafe fn is_niched(niched: *const NichedOption<T, N1>) -> bool

Returns whether the given value has been niched. Read more
Source§

fn resolve_niched(out: Place<NichedOption<T, N1>>)

Writes data to out indicating that a T is niched.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Pointee for T

Source§

type Metadata = ()

The metadata type for pointers and references to this type.
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more