laravel-rust 0.1.0

Laravel for Rust: a full-stack Rust web framework, inspired by PHP Laravel
Documentation
//! Store slow results, such as a report or an API response, and read them back on later requests.
//!
//! The cache keeps typed values in named stores, each backed by a driver: `memory`, `database`,
//! `redis`, `failover`, `discard`, or one you register with [`Drivers::extend`]. The functions in
//! this module use the default store, which `CACHE_STORE` names. To use another store, pick it by
//! name with [`store`]. [`lock`] gives you an atomic lock that every process using the store shares.
//!
//! ```no_run
//! # #[derive(serde::Serialize, serde::Deserialize)] struct User;
//! # #[derive(serde::Serialize, serde::Deserialize)] struct Report;
//! # async fn generate_report() -> laravel::Result<Report> { Ok(Report) }
//! use laravel::cache;
//! use laravel::time::ToSpan;
//!
//! # async fn example(user: User) -> laravel::Result<()> {
//! cache::put("user:42", &user, 5.minutes()).await?;
//! let user: Option<User> = cache::get("user:42").await?;
//!
//! let report: Report = cache::store("reports")?
//!     .remember("monthly", 10.minutes(), || async { generate_report().await })
//!     .await?;
//! # Ok(()) }
//! ```
//!
//! The cache manager creates each store on first use. A store connects to its backend only when
//! it first reads or writes a value, so an unreachable database never stops the application from
//! booting.
//!
//! To learn about configuration, locks, and testing, check out the
//! [cache guide](https://github.com/laravel/rust-framework/blob/0.x/docs/cache.md).

mod commands;
#[cfg(feature = "database")]
mod database;

pub(crate) use laravel_cache::cache::*;
#[doc(inline)]
pub use laravel_cache::cache::{
    Block, CacheManager, DiscardStore, Drivers, Lock, LockTimeout, MemoryStore, Repository, Store, StoreDefinition,
    add, decrement, flexible, flush, forget, get, has, increment, increment_or_add, lock, manager, many, memo, pull,
    put, put_many, remember, restore_lock, store, touch,
};

/// Define a migration's `migrate` function to create the `database` cache store's tables.
///
/// Put the macro alone in a migration file, and it creates the `cache` and `cache_locks` tables. To change the
/// tables, replace the macro with the migration the
/// [cache guide](https://github.com/laravel/rust-framework/blob/0.x/docs/cache.md#the-database-store) shows,
/// then edit it.
///
/// ```
/// // database/migrations/0001_01_01_000001_create_cache_table.rs
/// laravel::cache::tables!();
/// ```
#[cfg(feature = "database")]
pub use laravel_rust_database_macros::cache_tables as tables;

pub(crate) use self::commands::CacheServiceProvider;

/// The factory for the database store, or `None` without the `database` feature.
pub(crate) const DATABASE_STORE: Option<DatabaseStoreFactory> = {
    #[cfg(feature = "database")]
    {
        Some(database::create)
    }
    #[cfg(not(feature = "database"))]
    {
        None
    }
};