You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: cache.rs
    path of file: ./repos/vulkano/vulkano/src
    
    the code of the file until where you have to start completion: use ahash::HashMap;
use parking_lot::RwLock;
use std::{
    collections::hash_map::Entry,
    hash::Hash,
    sync::{Arc, Weak},
};

/// A map specialized to caching properties that are specific to a Vulkan implementation.
///
/// Readers never block each other, except when an entry is vacant. In that case it gets written to
/// once and then never again, entries are immutable after insertion.
#[derive(Debug)]
pub(crate) struct OnceCache<K, V> {
    inner: RwLock<HashMap<K, V>>,
}

impl<K, V> Default for OnceCache<K, V> {
    fn default() -> Self {
        Self {
            inner: RwLock::new(HashMap::default()),
        }
    }
}

impl<K, V> OnceCache<K, V> {
    /// Creates a new `OnceCache`.
    pub fn new() -> Self {
        Self::default()
    }
}

impl<K, V> Onc
    
    pub(crate) fn get_or_insert(&self, key: K, f: impl FnOnce(&K) -> Arc<V>) -> Arc<V> {
        if let Some(arc) = self.get(&key) {
            return arc;
        }

        match self.inner.write().entry(key) {
            Entry::Occupied(mut entry) => {
                if let Some(arc) = Weak::upgrade(entry.get()) {
                    // This can happen if someone else inserted an entry between when we released
                    // the read lock and acquired the write lock.
                    arc
                } else {
                    // The weak reference could not be upgraded, so create a new one.
                    let arc = f(entry.key());
                    entry.insert(Arc::downgrade(&arc));
                    arc
                }
            }
            Entry::Vacant(entry) => {
                let arc = f(entry.key());
                entry.insert(Arc::downgrade(&arc));
                arc
            }
        }
    }