pub struct AccessFrequencyCache { /* private fields */ }Expand description
Per-turn access frequency aggregator backed by fact_access_log.
Loads raw access counts for a candidate set in a single GROUP BY query per turn.
Normalized values are log(1 + count) / log(1 + MAX_ACCESS_COUNT) ∈ [0.0, 1.0].
Implementations§
Source§impl AccessFrequencyCache
impl AccessFrequencyCache
Sourcepub async fn load_for_candidates(
&self,
session_id: &str,
fact_ids: &[MessageId],
) -> Result<HashMap<MessageId, f64>, MemoryError>
pub async fn load_for_candidates( &self, session_id: &str, fact_ids: &[MessageId], ) -> Result<HashMap<MessageId, f64>, MemoryError>
Load and normalize access counts for fact_ids within session_id.
Issues a single SQL GROUP BY query indexed by (session_id, accessed_at DESC).
Returns a map of fact_id → normalized_score ∈ [0.0, 1.0].
§Errors
Returns an error if the database query fails.
Sourcepub async fn log_access(
&self,
fact_id: MessageId,
fact_type: &str,
session_id: &str,
)
pub async fn log_access( &self, fact_id: MessageId, fact_type: &str, session_id: &str, )
Record a fact access event in fact_access_log.
Failures are logged as WARN and do not propagate — access logging is non-critical.
Auto Trait Implementations§
impl Freeze for AccessFrequencyCache
impl !RefUnwindSafe for AccessFrequencyCache
impl Send for AccessFrequencyCache
impl Sync for AccessFrequencyCache
impl Unpin for AccessFrequencyCache
impl UnsafeUnpin for AccessFrequencyCache
impl !UnwindSafe for AccessFrequencyCache
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request