Monday, November 30, 2015

.NET Semaphore Slim that Supports Keys

While making a HUGE update to my CacheRepository project, I needed a way to have a dynamic number of semaphores that would lock on a specified cache key. The SemaphoreSlim is great, but I needed a wrapper around it that allowed me have one for each unique cache key being fetched.

The easiest solution was just to have a concurrent dictionary of string to semaphore, but at high load that would grow in size and I did not want to waste memory. Instead I created a class that does keep a dictionary of semaphores, but then removes them from the dictionary and stores them in a queue for reuse once there is nothing locking off on them.

Enough talking! Below is the code, and as always it comes with unit tests! :)

Sunday, November 29, 2015

Obsolete Blog Posts

I was recently asked an interesting question:

"Are there any blog posts you wrote that you no longer agree with?"

Yes there are. As I have grown as a developer there are many patterns and practices that I have changed my opinions about. Also, many of my posts are related to specific technologies that have grown, changed, or become deprecated over time.

Here is a small list of posts on my blog that I now consider to be obsolete.

Going back through these posts to write this post has made me notice a common theme as I grow: I continue to advocate simpler solutions to problems. I like that trend, and I can't wait to see what I am writing about in another 7 years.

Live and learn,
Tom

Wednesday, November 25, 2015

.NET WebSocket Libraries

WebSockets are awesome, and you should be using them. If you are working with .NET, then there are some very easy to consume libraries to help you host a WebSocket server or connect as a WebSocket client.

Below is a complete chat server and client made using ONLY these two libraries.

Real Time Web Analytics