diff --git a/Atomic.md b/Atomic.md index d9928c1..0836a18 100644 --- a/Atomic.md +++ b/Atomic.md @@ -1,33 +1,3 @@ # Atomicness -When it comes ot atomicness, the biggest challenge is to check "item exists" and "item not expired" in one go. - -When an item was "found but is expired" - we need to treat this as "not found" and discard it. For that we either need to use a lock -so that the the three steps "exist? expired? remove!" are performed atomically. Otherwise another tread might chip in, -and ADD a non-expired item with the same key while we're evicting it. And we'll be removing a non-expired key taht was just added - -OR instead of using locks we can remove _by key AND by value_. So if another thread has just rushed in -and added another item with the same key - that other item won't be removed. - -basically, instead of doing this - -``` -lock { - exists? - expired? - remove by key! -} -``` - -we do this - -``` -exists? (if yes returns the value) -expired? -remove by key AND value -``` - -If another thread chipped in while we were in the middle of checking if it's expired or not, and recorded a new value - we won't remove it. - -Locks suck becasue add extra 50ns to benchmark, so it becomes 110ns instead of 70ns which sucks. -So - no locks then! +The article has been moved [here](https://www.jitbit.com/alexblog/fast-memory-cache/#perf) diff --git a/README.md b/README.md index b31e4b9..ddbe40f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # FastCache -7x-10x faster alternative to MemoryCache. A high-performance, lighweight (8KB dll) and thread-safe memory cache for .NET. +7x-10x faster alternative to MemoryCache. A high-performance, lighweight (8KB dll) and [thread-safe](Atomic.md) memory cache for .NET. [![NuGet version](https://badge.fury.io/nu/jitbit.fastcache.svg)](https://badge.fury.io/nu/jitbit.fastcache) [![.NET](https://github.com/jitbit/FastCache/actions/workflows/dotnet.yml/badge.svg)](https://github.com/jitbit/FastCache/actions/workflows/dotnet.yml)