Skip to main content

FileStore

Struct FileStore 

Source
pub struct FileStore { /* private fields */ }
Expand description

A cache stored on disk. Cloning shares one directory and one lock table.

Implementations§

Source§

impl FileStore

Source

pub fn new(directory: impl Into<PathBuf>) -> Result<Self>

Create a store rooted at directory, creating the directory if needed.

Source

pub fn with_prefix( directory: impl Into<PathBuf>, prefix: impl Into<String>, ) -> Result<Self>

Source

pub fn directory(&self) -> &Path

Source

pub fn path_for(&self, key: &str) -> PathBuf

The file backing a key. Public so a test can prove where a hostile key actually lands.

Trait Implementations§

Source§

impl Cache for FileStore

Source§

fn driver(&self) -> &'static str

The driver’s name, used in cache.hit / cache.miss events and in error messages. Telescope shows it as the store column.
Source§

fn get<'a>(&'a self, key: &'a str) -> BoxFuture<'a, Result<Option<Json>>>

Fetch a value, or None when it is missing or expired. Read more
Source§

fn put<'a>( &'a self, key: &'a str, value: Json, ttl: Duration, ) -> BoxFuture<'a, Result<()>>

Store a value that expires after ttl. Read more
Source§

fn forever<'a>(&'a self, key: &'a str, value: Json) -> BoxFuture<'a, Result<()>>

Store a value with no expiry. It still goes away on Cache::flush.
Source§

fn forget<'a>(&'a self, key: &'a str) -> BoxFuture<'a, Result<bool>>

Remove a key. Returns whether something was actually there.
Source§

fn flush(&self) -> BoxFuture<'_, Result<()>>

Remove everything this store owns.
Source§

fn increment<'a>(&'a self, key: &'a str, by: i64) -> BoxFuture<'a, Result<i64>>

Add by to a counter, creating it at zero first. Returns the new value. Read more
Source§

fn increment_within<'a>( &'a self, key: &'a str, by: i64, ttl: Duration, ) -> BoxFuture<'a, Result<i64>>

Increment a counter, giving it ttl only when this call created it. Read more
Source§

fn ttl<'a>(&'a self, key: &'a str) -> BoxFuture<'a, Result<Option<Duration>>>

How long until a key expires: None when it is missing or immortal. Read more
Source§

fn has<'a>(&'a self, key: &'a str) -> BoxFuture<'a, Result<bool>>

Whether a live (unexpired) value exists.
Source§

fn decrement<'a>(&'a self, key: &'a str, by: i64) -> BoxFuture<'a, Result<i64>>

Subtract by from a counter. Returns the new value.
Source§

fn pull<'a>(&'a self, key: &'a str) -> BoxFuture<'a, Result<Option<Json>>>

Read a value and remove it in one call — Laravel’s Cache::pull.
Source§

impl Clone for FileStore

Source§

fn clone(&self) -> FileStore

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

Auto Trait Implementations§

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> 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> CacheExt for T
where T: Cache + ?Sized,

Source§

fn remember<'a, F, Fut>( &'a self, key: &'a str, ttl: Duration, compute: F, ) -> impl Future<Output = Result<Json>> + Send + 'a
where F: FnOnce() -> Fut + Send + 'a, Fut: Future<Output = Result<Json>> + Send + 'a,

Return the cached value, or compute it, store it for ttl, and return it. Read more
Source§

fn remember_forever<'a, F, Fut>( &'a self, key: &'a str, compute: F, ) -> impl Future<Output = Result<Json>> + Send + 'a
where F: FnOnce() -> Fut + Send + 'a, Fut: Future<Output = Result<Json>> + Send + 'a,

CacheExt::remember with no expiry.
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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = !

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.