pdk-cache-lib 1.9.0-alpha.3

PDK Cache Library
Documentation
// Copyright (c) 2026, Salesforce, Inc.,
// All rights reserved.
// For full license text, see the LICENSE.txt file

#[cfg(test)]
use {
    mockall::mock,
    pdk_core::classy::shared_data::concurrent_shared_data::TransactionStatus,
    serde::{de::DeserializeOwned, Serialize},
};

#[cfg(test)]
mock! {
    pub ConcurrentSharedData {

        pub fn new(clock: std::rc::Rc<dyn pdk_core::classy::Clock>, shared_data: std::rc::Rc<dyn pdk_core::classy::SharedData>) -> Self;

        pub fn insert<T, F>(
           &self,
           key: String,
           data: T,
           handle_consistency: F,
       ) -> (TransactionStatus, T)
       where
           T: Clone + Serialize + DeserializeOwned + 'static,
           F: Fn(T, T) -> Option<T> + 'static;

       pub fn get<T>(&self, key: &str) -> Option<T>
           where
               T: Clone + Serialize + DeserializeOwned + 'static ;

        pub fn remove<T>(&self, key: &str) -> Option<T>
        where
            T: Clone + Serialize + DeserializeOwned + 'static;
    }
}