pub struct CacheEvent {Show 16 fields
pub timestamp: SystemTime,
pub event_type: CacheEventType,
pub request_id: RequestId,
pub key: String,
pub method: Option<Method>,
pub uri: Option<Uri>,
pub version: Option<Version>,
pub status: Option<StatusCode>,
pub hit: bool,
pub latency_us: Option<u64>,
pub size_bytes: Option<usize>,
pub ttl_seconds: Option<u64>,
pub tags: Option<Vec<String>>,
pub tier: Option<String>,
pub promoted: bool,
pub metadata: Value,
}Expand description
Structured cache event for ML training. Structured cache event, emitted as JSON.
Requires the serde feature: the metadata field is a
serde_json::Value and the payload is emitted as JSON.
Fields§
§timestamp: SystemTimeTimestamp of the event
event_type: CacheEventTypeType of cache event
request_id: RequestIdRequest ID for correlation
key: StringCache key (may be hashed)
method: Option<Method>Request method
uri: Option<Uri>Request URI
version: Option<Version>HTTP version
status: Option<StatusCode>Response status code
hit: boolWhether this was a cache hit
latency_us: Option<u64>Operation latency in microseconds
size_bytes: Option<usize>Response size in bytes
ttl_seconds: Option<u64>TTL in seconds
Cache tags associated with this entry
tier: Option<String>Tier information (l1, l2, or None)
promoted: boolWhether entry was promoted between tiers
metadata: ValueAdditional metadata
Implementations§
Source§impl CacheEvent
impl CacheEvent
Sourcepub fn new(
event_type: CacheEventType,
request_id: RequestId,
key: String,
) -> Self
pub fn new( event_type: CacheEventType, request_id: RequestId, key: String, ) -> Self
Creates a new cache event.
Sourcepub fn with_method(self, method: Method) -> Self
pub fn with_method(self, method: Method) -> Self
Sets the HTTP method.
Sourcepub fn with_version(self, version: Version) -> Self
pub fn with_version(self, version: Version) -> Self
Sets the HTTP version.
Sourcepub fn with_status(self, status: StatusCode) -> Self
pub fn with_status(self, status: StatusCode) -> Self
Sets the response status.
Sourcepub fn with_latency(self, latency: Duration) -> Self
pub fn with_latency(self, latency: Duration) -> Self
Sets the operation latency.
Sets the cache tags.
Sourcepub fn with_promoted(self, promoted: bool) -> Self
pub fn with_promoted(self, promoted: bool) -> Self
Sets whether the entry was promoted.
Sourcepub fn with_metadata(self, metadata: Value) -> Self
pub fn with_metadata(self, metadata: Value) -> Self
Adds custom metadata.
Sourcepub fn log(&self, config: &MLLoggingConfig)
pub fn log(&self, config: &MLLoggingConfig)
Logs this event using the provided configuration.
Trait Implementations§
Source§impl Clone for CacheEvent
impl Clone for CacheEvent
Source§fn clone(&self) -> CacheEvent
fn clone(&self) -> CacheEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more