Skip to content

Instantly share code, notes, and snippets.

View crisanvlad's full-sized avatar
🎯
Focusing

Vlad crisanvlad

🎯
Focusing
View GitHub Profile
class Cache<Key: Hashable, Value> {
private let _cache: OSAllocatedUnfairLock<[Key: Value]>
init() {
_cache = OSAllocatedUnfairLock(initialState: [:])
}
func get(_ key: Key) -> Value? {
_cache.withLock { cache in
cache[key]