Struct async_graphql::dataloader::DataLoader[][src]

pub struct DataLoader<T, C = NoCache> { /* fields omitted */ }
This is supported on crate feature dataloader only.

Implementations

impl<T> DataLoader<T, NoCache>[src]

pub fn new(loader: T) -> Self[src]

Use Loader to create a DataLoader that does not cache records.

impl<T, C: CacheFactory> DataLoader<T, C>[src]

pub fn with_cache(loader: T, cache_factory: C) -> Self[src]

Use Loader to create a DataLoader with a cache factory.

pub fn delay(self, delay: Duration) -> Self[src]

Specify the delay time for loading data, the default is 1ms.

pub fn max_batch_size(self, max_batch_size: usize) -> Self[src]

pub fn Specify the max batch size for loading data, the default is 1000.

If the keys waiting to be loaded reach the threshold, they are loaded immediately.

pub fn loader(&self) -> &T[src]

Get the loader.

pub async fn load_one<K>(&self, key: K) -> Result<Option<T::Value>, T::Error> where
    K: Send + Sync + Hash + Eq + Clone + 'static,
    T: Loader<K>, 
[src]

Use this DataLoader load a data.

pub async fn load_many<K, I>(
    &self,
    keys: I
) -> Result<HashMap<K, T::Value>, T::Error> where
    K: Send + Sync + Hash + Eq + Clone + 'static,
    I: IntoIterator<Item = K>,
    T: Loader<K>, 
[src]

Use this DataLoader to load some data.

pub async fn feed_many<K, I>(&self, values: I) where
    K: Send + Sync + Hash + Eq + Clone + 'static,
    I: IntoIterator<Item = (K, T::Value)>,
    T: Loader<K>, 
[src]

Feed some data into the cache.

**NOTE: If the cache type is NoCache, this function will not take effect. **

pub async fn feed_one<K>(&self, key: K, value: T::Value) where
    K: Send + Sync + Hash + Eq + Clone + 'static,
    T: Loader<K>, 
[src]

Feed some data into the cache.

**NOTE: If the cache type is NoCache, this function will not take effect. **

pub fn clear<K>(&self) where
    K: Send + Sync + Hash + Eq + Clone + 'static,
    T: Loader<K>, 
[src]

Clears the cache.

**NOTE: If the cache type is NoCache, this function will not take effect. **

Auto Trait Implementations

impl<T, C> RefUnwindSafe for DataLoader<T, C> where
    C: RefUnwindSafe,
    T: RefUnwindSafe

impl<T, C> Send for DataLoader<T, C> where
    C: Send,
    T: Send

impl<T, C> Sync for DataLoader<T, C> where
    C: Sync,
    T: Sync

impl<T, C> Unpin for DataLoader<T, C> where
    C: Unpin,
    T: Unpin

impl<T, C> UnwindSafe for DataLoader<T, C> where
    C: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> FutureExt for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]