pub enum SessionBackend {
Sqlite(SqliteSessionStore),
CloudflareKv(KvSessionStore),
}Expand description
Pluggable session storage backend
Variants§
Sqlite(SqliteSessionStore)
Local SQLite storage (default)
CloudflareKv(KvSessionStore)
Cloudflare Workers KV via REST API
Implementations§
Source§impl SessionBackend
impl SessionBackend
Sourcepub async fn update(&self, id: &str, data: HashMap<String, Value>) -> Result<()>
pub async fn update(&self, id: &str, data: HashMap<String, Value>) -> Result<()>
Update session data
Sourcepub async fn cleanup_expired(&self) -> Result<u64>
pub async fn cleanup_expired(&self) -> Result<u64>
Clean up expired sessions (no-op for KV which uses TTL)
Sourcepub async fn list_session_ids(&self) -> Result<Vec<String>>
pub async fn list_session_ids(&self) -> Result<Vec<String>>
List active session IDs (SQLite only, returns empty for KV)
Sourcepub async fn count(&self) -> Result<usize>
pub async fn count(&self) -> Result<usize>
Count active sessions (SQLite only, returns 0 for KV)
Sourcepub async fn apply_mutation(
&self,
id: &str,
mutation: &AtomicMutation,
) -> Result<HashMap<String, Value>>
pub async fn apply_mutation( &self, id: &str, mutation: &AtomicMutation, ) -> Result<HashMap<String, Value>>
Apply an atomic mutation directly at the storage level. For SQLite, this uses SQL json_set/json_extract for atomicity. For KV, falls back to read-modify-write (KV doesn’t support atomic ops). Returns the updated session data after the mutation.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for SessionBackend
impl !UnwindSafe for SessionBackend
impl Freeze for SessionBackend
impl Send for SessionBackend
impl Sync for SessionBackend
impl Unpin for SessionBackend
impl UnsafeUnpin for SessionBackend
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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