PathCacher

Struct PathCacher 

Source
pub struct PathCacher<Q: PathQuery> { /* private fields */ }
Available on crate feature internal-path-cache only.
Expand description

PathCacher is a cache for path query.

OpenDAL is designed for path based storage systems, such as S3, HDFS, etc. But there are many services that are not path based, such as OneDrive, Google Drive, etc. For these services, we look up files based on id. The lookup of id is very expensive, so we cache the path to id mapping in PathCacher.

§Behavior

The path in the cache is always an absolute one. For example, if the service root is /root/, then the path of file a/b in cache will be /root/a/b.

Implementations§

Source§

impl<Q: PathQuery> PathCacher<Q>

Source

pub fn new(query: Q) -> Self

Create a new path cacher.

Source

pub fn with_lock(self) -> Self

Enable the lock for the path cacher.

Source

pub async fn insert(&self, path: &str, id: &str)

Insert a new cache entry.

Source

pub async fn remove(&self, path: &str)

Remove a cache entry.

Source

pub async fn get(&self, path: &str) -> Result<Option<String>>

Get the id for the given path.

Source

pub async fn ensure_dir(&self, path: &str) -> Result<String>

Ensure input dir exists.

Auto Trait Implementations§

§

impl<Q> !Freeze for PathCacher<Q>

§

impl<Q> !RefUnwindSafe for PathCacher<Q>

§

impl<Q> Send for PathCacher<Q>
where Q: Send,

§

impl<Q> Sync for PathCacher<Q>
where Q: Sync,

§

impl<Q> Unpin for PathCacher<Q>
where Q: Unpin,

§

impl<Q> !UnwindSafe for PathCacher<Q>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> MaybeSend for T
where T: Send,