Skip to content

Commit f10e245

Browse files
committed
document async_std feature
1 parent 30d00be commit f10e245

File tree

2 files changed

+42
-7
lines changed

2 files changed

+42
-7
lines changed

README.md

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,23 @@
1919
### sqlite:
2020

2121
```toml
22-
async-sqlx-session = { version = "0.2.0", features = ["sqlite"] }
22+
async-sqlx-session = { version = "0.3.0", features = ["sqlite"] }
2323
```
2424

2525
### postgres:
2626

2727
```toml
28-
async-sqlx-session = { version = "0.2.0", features = ["pg"] }
28+
async-sqlx-session = { version = "0.3.0", features = ["pg"] }
2929
```
3030

31+
### Optional `async_std` feature
32+
33+
To use the `spawn_cleanup_task` function on async-std, enable the
34+
`async_std` feature.
35+
36+
```toml
37+
async-sqlx-session = { version = "0.3.0", features = ["pg", "async_std"] }
38+
```
3139

3240

3341
## Cargo Features:

src/lib.rs

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,35 @@
1-
//! # async-sqlx-session
2-
//!
3-
//! This crate currently provides two session stores: [`PostgresSessionStore`] and [`SqliteSessionStore`], each of which is enabled by a feature flag.
4-
//! To use `SqliteSessionStore`, enable the `sqlite` feature on this crate.
5-
//! To use `PostgresSessionStore`, enable the `pg` feature on this crate.
1+
/*!
2+
# async-sqlx-session
3+
4+
This crate currently provides two session stores:
5+
[`PostgresSessionStore`] and [`SqliteSessionStore`], each of which
6+
is enabled by a feature flag.
7+
8+
To use [`SqliteSessionStore`], enable the `sqlite` feature on this
9+
crate.
10+
11+
To use [`PostgresSessionStore`], enable the `pg` feature on this
12+
crate.
13+
14+
To use the `spawn_cleanup_task` function for either store on
15+
async-std, enable the `async_std` feature. To perform session cleanup
16+
intermittently with a different runtime, use a function like:
17+
18+
```rust,ignore
19+
fn clean_up_intermittently(store: &SqliteSessionStore, period: Duration) {
20+
let store = store.clone();
21+
other_runtime::spawn(async move {
22+
loop {
23+
other_runtime::sleep(period).await;
24+
if let Err(error) = store.cleanup().await {
25+
log::error!("cleanup error: {}", error);
26+
}
27+
}
28+
});
29+
}
30+
```
31+
*/
32+
633
#![forbid(unsafe_code, future_incompatible)]
734
#![deny(
835
missing_debug_implementations,

0 commit comments

Comments
 (0)