From 897d89b2813f42448e96d60730a98a695245ec91 Mon Sep 17 00:00:00 2001 From: Hugo Sjoberg Date: Wed, 20 Sep 2023 18:40:20 -0700 Subject: [PATCH] Fix singleflight blog --- content/english/blog/golang/singleflight.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/content/english/blog/golang/singleflight.md b/content/english/blog/golang/singleflight.md index 4807de8..3e745b0 100644 --- a/content/english/blog/golang/singleflight.md +++ b/content/english/blog/golang/singleflight.md @@ -1,3 +1,17 @@ +--- +title: "Singleflight" +meta_title: "" +description: "Singleflight in Golang" +date: 2022-04-04T05:00:00Z +image: "/images/singleflight.png" +categories: ["golang", "concurrency"] +author: "Hugo Sjoberg" +tags: ["golang", "concurrency"] +draft: false +--- + +# Why Singleflight? + Imagine you are running a service that calls a slow operation, let's say it makes an expensive query to a database. Now this particular service is a popular one, before the first query even returned a result 10 more identical requests were made. Wouldn't it be nice if we didn't have to call the database 10 times but instead return the data we get back from the first request to all other requests?