Skip to content

Commit

Permalink
Merge branch 'main' into replace-with-time
Browse files Browse the repository at this point in the history
  • Loading branch information
jbr committed Dec 13, 2022
2 parents a4de37f + 176f774 commit d28cef3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "daily"
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,15 @@
* [async-sqlx-session](https://crates.io/crates/async-sqlx-session) postgres & sqlite
* [async-redis-session](https://crates.io/crates/async-redis-session)
* [async-mongodb-session](https://crates.io/crates/async-mongodb-session)
* [async-session-r2d2](https://crates.io/crates/async-session-r2d2) - sqlite only

## Framework implementations

* [`tide::sessions`](https://docs.rs/tide/latest/tide/sessions/index.html)
* [warp-sessions](https://docs.rs/warp-sessions/latest/warp_sessions/)
* [trillium-sessions](https://docs.trillium.rs/trillium_sessions)
* [axum-sessions](https://docs.rs/axum_sessions)
* [salvo-sessions](https://docs.rs/salvo_extra/latest/salvo_extra/session/index.html)

## Safety
This crate uses ``#![deny(unsafe_code)]`` to ensure everything is implemented in
Expand Down
14 changes: 7 additions & 7 deletions src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use time::OffsetDateTime as DateTime;
/// and read exactly once in order to set the cookie value.
///
/// ## Change tracking session tracks whether any of its inner data
/// was changed since it was last serialized. Any sessoin store that
/// was changed since it was last serialized. Any session store that
/// does not undergo a serialization-deserialization cycle must call
/// [`Session::reset_data_changed`] in order to reset the change tracker on
/// an individual record.
Expand Down Expand Up @@ -157,7 +157,7 @@ impl Session {
/// assert!(session.is_destroyed());
/// # Ok(()) }) }
pub fn destroy(&mut self) {
self.destroy.store(true, Ordering::Relaxed);
self.destroy.store(true, Ordering::SeqCst);
}

/// returns true if this session is marked for destruction
Expand All @@ -174,7 +174,7 @@ impl Session {
/// # Ok(()) }) }

pub fn is_destroyed(&self) -> bool {
self.destroy.load(Ordering::Relaxed)
self.destroy.load(Ordering::SeqCst)
}

/// Gets the session id
Expand Down Expand Up @@ -230,7 +230,7 @@ impl Session {
let mut data = self.data.write().unwrap();
if data.get(key) != Some(&value) {
data.insert(key.to_string(), value);
self.data_changed.store(true, Ordering::Relaxed);
self.data_changed.store(true, Ordering::Release);
}
}

Expand Down Expand Up @@ -281,7 +281,7 @@ impl Session {
pub fn remove(&mut self, key: &str) {
let mut data = self.data.write().unwrap();
if data.remove(key).is_some() {
self.data_changed.store(true, Ordering::Relaxed);
self.data_changed.store(true, Ordering::Release);
}
}

Expand Down Expand Up @@ -479,7 +479,7 @@ impl Session {
/// # Ok(()) }) }
/// ```
pub fn data_changed(&self) -> bool {
self.data_changed.load(Ordering::Relaxed)
self.data_changed.load(Ordering::Acquire)
}

/// Resets `data_changed` dirty tracking. This is unnecessary for
Expand All @@ -503,7 +503,7 @@ impl Session {
/// # Ok(()) }) }
/// ```
pub fn reset_data_changed(&self) {
self.data_changed.store(false, Ordering::Relaxed);
self.data_changed.store(false, Ordering::SeqCst);
}

/// Ensures that this session is not expired. Returns None if it is expired
Expand Down

0 comments on commit d28cef3

Please sign in to comment.