#[non_exhaustive]pub struct MediaRetentionPolicy {
pub max_cache_size: Option<usize>,
pub max_file_size: Option<usize>,
pub last_access_expiry: Option<Duration>,
}
Expand description
The retention policy for media content used by the EventCacheStore
.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.max_cache_size: Option<usize>
The maximum authorized size of the overall media cache, in bytes.
The cache size is defined as the sum of the sizes of all the (possibly encrypted) media contents in the cache, excluding any metadata associated with them.
If this is set and the cache size is bigger than this value, the oldest media contents in the cache will be removed during a cleanup until the cache size is below this threshold.
Note that it is possible for the cache size to temporarily exceed this value between two cleanups.
Defaults to 400 MiB.
max_file_size: Option<usize>
The maximum authorized size of a single media content, in bytes.
The size of a media content is the size taken by the content in the database, after it was possibly encrypted, so it might differ from the initial size of the content.
The maximum authorized size of a single media content is actually the
lowest value between max_cache_size
and max_file_size
.
If it is set, media content bigger than the maximum size will not be cached. If the maximum size changed after media content that exceeds the new value was cached, the corresponding content will be removed during a cleanup.
Defaults to 20 MiB.
last_access_expiry: Option<Duration>
The duration after which unaccessed media content is considered expired.
If this is set, media content whose last access is older than this duration will be removed from the media cache during a cleanup.
Defaults to 60 days.
Implementations§
Source§impl MediaRetentionPolicy
impl MediaRetentionPolicy
Sourcepub fn new() -> MediaRetentionPolicy
pub fn new() -> MediaRetentionPolicy
Create a MediaRetentionPolicy
with the default values.
Sourcepub fn empty() -> MediaRetentionPolicy
pub fn empty() -> MediaRetentionPolicy
Create an empty MediaRetentionPolicy
.
This means that all media will be cached and cleanups have no effect.
Sourcepub fn with_max_cache_size(self, size: Option<usize>) -> MediaRetentionPolicy
pub fn with_max_cache_size(self, size: Option<usize>) -> MediaRetentionPolicy
Set the maximum authorized size of the overall media cache, in bytes.
Sourcepub fn with_max_file_size(self, size: Option<usize>) -> MediaRetentionPolicy
pub fn with_max_file_size(self, size: Option<usize>) -> MediaRetentionPolicy
Set the maximum authorized size of a single media content, in bytes.
Sourcepub fn with_last_access_expiry(
self,
duration: Option<Duration>,
) -> MediaRetentionPolicy
pub fn with_last_access_expiry( self, duration: Option<Duration>, ) -> MediaRetentionPolicy
Set the duration before which unaccessed media content is considered expired.
Sourcepub fn has_limitations(&self) -> bool
pub fn has_limitations(&self) -> bool
Whether this policy has limitations.
If this policy has no limitations, a cleanup job would have no effect.
Returns true
if at least one limitation is set.
Sourcepub fn exceeds_max_cache_size(&self, size: usize) -> bool
pub fn exceeds_max_cache_size(&self, size: usize) -> bool
Whether the given size exceeds the maximum authorized size of the media cache.
§Arguments
size
- The overall size of the media cache to check, in bytes.
Sourcepub fn computed_max_file_size(&self) -> Option<usize>
pub fn computed_max_file_size(&self) -> Option<usize>
The computed maximum authorized size of a single media content, in bytes.
This is the lowest value between max_cache_size
and max_file_size
.
Sourcepub fn exceeds_max_file_size(&self, size: usize) -> bool
pub fn exceeds_max_file_size(&self, size: usize) -> bool
Whether the given size, in bytes, exceeds the computed maximum authorized size of a single media content.
§Arguments
size
- The size of the media content to check, in bytes.
Sourcepub fn has_content_expired(
&self,
current_time: SystemTime,
last_access_time: SystemTime,
) -> bool
pub fn has_content_expired( &self, current_time: SystemTime, last_access_time: SystemTime, ) -> bool
Whether a content whose last access was at the given time has expired.
§Arguments
-
current_time
- The current time. -
last_access_time
- The time when the media content to check was last accessed.
Trait Implementations§
Source§impl Clone for MediaRetentionPolicy
impl Clone for MediaRetentionPolicy
Source§fn clone(&self) -> MediaRetentionPolicy
fn clone(&self) -> MediaRetentionPolicy
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for MediaRetentionPolicy
impl Debug for MediaRetentionPolicy
Source§impl Default for MediaRetentionPolicy
impl Default for MediaRetentionPolicy
Source§fn default() -> MediaRetentionPolicy
fn default() -> MediaRetentionPolicy
Source§impl<'de> Deserialize<'de> for MediaRetentionPolicy
impl<'de> Deserialize<'de> for MediaRetentionPolicy
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<MediaRetentionPolicy, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<MediaRetentionPolicy, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for MediaRetentionPolicy
impl PartialEq for MediaRetentionPolicy
Source§impl Serialize for MediaRetentionPolicy
impl Serialize for MediaRetentionPolicy
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for MediaRetentionPolicy
impl Eq for MediaRetentionPolicy
impl StructuralPartialEq for MediaRetentionPolicy
Auto Trait Implementations§
impl Freeze for MediaRetentionPolicy
impl RefUnwindSafe for MediaRetentionPolicy
impl Send for MediaRetentionPolicy
impl Sync for MediaRetentionPolicy
impl Unpin for MediaRetentionPolicy
impl UnwindSafe for MediaRetentionPolicy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> CompatExt for T
impl<T> CompatExt for T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
Source§fn consume_handle(handle: Handle) -> Arc<T>
fn consume_handle(handle: Handle) -> Arc<T>
Arc<>
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more