{"id":220,"date":"2016-12-21T07:00:38","date_gmt":"2016-12-21T05:00:38","guid":{"rendered":"http:\/\/qappdesign.com\/?p=220"},"modified":"2017-03-03T11:08:19","modified_gmt":"2017-03-03T09:08:19","slug":"distributed-cache-using-redis-and-aspnet-core","status":"publish","type":"post","link":"https:\/\/qappdesign.com\/code\/distributed-cache-using-redis-and-aspnet-core\/","title":{"rendered":"Distributed cache using Redis and ASP.NET Core"},"content":{"rendered":"<h4>What is Redis ?<\/h4>\n<p>Redis is a super fast non-relational database that uses keys to map to different data types. It is a key value data store (NoSQL) allowing to solve efficiently many different problem sets. Redis was created by Salvatore Sanfilippo in 2009, and Sanfilippo still remains the lead developer of the project today. It is a mature and hugely popular open source project, being used by many companies and in countless mission-critical production environments.<\/p>\n<p>Here is an <a href=\"https:\/\/blog.pivotal.io\/pivotal\/pivotal-people\/pivotal-people-salvatore-sanfilippo-inventor-of-redis\" target=\"_blank\">interview<\/a> with the inventor of Redis, Salvatore Sanfilippo.<\/p>\n<h4>Why is Redis popular?<\/h4>\n<p>Not only is it extremely effective, but it is also relatively simple. Getting started with Redis is quite fast, and it usually takes only a few minutes to set up and get them working within an application. Thus, a small investment of time and effort can have an immediate, dramatic impact on performance of the application.  <\/p>\n<p>Just to name two cases when Redis is helpful:<\/p>\n<ul>\n<li>Redis is used at Pinterest &#8211; see <a href=\"https:\/\/www.hakkalabs.co\/articles\/redis-at-pinterest-transcript\/\" target=\"_blank\">use case<\/a><\/li>\n<li>or at Twitter, where Raffi Kirkorian, VP of Engineering at Twitter, explains how Redis helps to support over 30 billion timeline updates per day based on 5000 tweets per second or 400,000,000 tweets per day &#8211; <a href=\"https:\/\/www.infoq.com\/presentations\/Twitter-Timeline-Scalability\" target=\"_blank\">see here the presentation<\/a>.<\/li>\n<\/ul>\n<h4>Easy access the code<\/h4>\n<p>The full client web application that display the Twitter messages could be found on <a href=\"https:\/\/github.com\/fpetru\/redis-aspnetcore-caching\" target=\"_blank\">Github &#8211; https:\/\/github.com\/fpetru\/redis-aspnetcore-caching<\/a>. <\/p>\n<h4>To install<\/h4>\n<p>Here are all the things needed to be installed locally:<\/p>\n<ul>\n<li><a href=\"https:\/\/go.microsoft.com\/fwlink\/?LinkId=691978\" target=\"_blank\">Visual Studio Community 2015 with Update 3<\/a> (or just <a href=\"https:\/\/go.microsoft.com\/fwlink\/?LinkId=691129\" target=\"_blank\">Update 3<\/a> if you have already installed) and <a href=\"https:\/\/go.microsoft.com\/fwlink\/?LinkID=827546\" target=\"_blank\">.NET Core 1.0.1 &#8211; VS 2015 Tooling Preview 2<\/a><\/li>\n<li><a href=\"https:\/\/www.microsoft.com\/net\/download\/core#\/current\" target=\"_blank\">.NET Core 1.1 SDK<\/a><\/li>\n<\/ul>\n<h4>Installing Redis Server on Windows<\/h4>\n<p>Create a new ASP.NET Core project, and from Nuget select for installing <em>Redis-64<\/em>. The server is installed in the default Nuget path. To start the server run next in command prompt:<\/p>\n<div class=\"hidenum\">\n<pre class=\"nums:false lang:default decode:true\">\r\nC:\\Users\\[logged in user]\\.nuget\\packages\\Redis-64\\[version installed]\\tools>redis-server.exe\r\n# in my case\r\nC:\\Users\\petru\\.nuget\\packages\\Redis-64\\3.0.503\\tools>redis-server.exe\r\n<\/pre>\n<\/div>\n<p><img loading=\"lazy\" width=\"677\" height=\"343\" src=\"data:image\/svg+xml,%3Csvg xmlns='http:\/\/www.w3.org\/2000\/svg' viewBox='0 0 677 343'%3E%3C\/svg%3E\" data-src=\"http:\/\/qappdesign.com\/wp-content\/uploads\/2016\/12\/Redis-server.jpg\" alt=\"redis-server\" class=\"alignnone size-medium wp-image-261 lazyload \" data-sizes=\"auto\" data-srcset=\"https:\/\/i0.wp.com\/qappdesign.com\/code\/wp-content\/uploads\/2016\/12\/Redis-server.jpg?w=677&amp;ssl=1 677w, https:\/\/i0.wp.com\/qappdesign.com\/code\/wp-content\/uploads\/2016\/12\/Redis-server.jpg?resize=300%2C152&amp;ssl=1 300w\" sizes=\"(max-width: 677px) 100vw, 677px\" \/><noscript><img loading=\"lazy\" width=\"677\" height=\"343\" src=\"https:\/\/i0.wp.com\/qappdesign.com\/wp-content\/uploads\/2016\/12\/Redis-server.jpg?resize=677%2C343\" alt=\"redis-server\" class=\"alignnone size-medium wp-image-261\" srcset=\"https:\/\/i0.wp.com\/qappdesign.com\/code\/wp-content\/uploads\/2016\/12\/Redis-server.jpg?w=677&amp;ssl=1 677w, https:\/\/i0.wp.com\/qappdesign.com\/code\/wp-content\/uploads\/2016\/12\/Redis-server.jpg?resize=300%2C152&amp;ssl=1 300w\" sizes=\"(max-width: 677px) 100vw, 677px\" data-recalc-dims=\"1\" \/><\/noscript><\/p>\n<p>In the same folder, there is a document describing how to install Redis as a Windows Service (check the file <em>Windows Service Documentation.docx<\/em>). For running the simple scenarios from this article, running just from command line should be enough.<\/p>\n<h4>Caching in ASP.NET Core using Redis<\/h4>\n<p>To use Redis in ASP.NET Core, we need to reference Microsoft.Extensions.Caching.Redis.Core package. Additionally, in our sample we would need also the Session package. Installing these could be done either using Nuget or extending the project.json file:<\/p>\n<pre>\r\n\"Microsoft.Extensions.Caching.Redis.Core\": \"1.0.3\",\r\n\"Microsoft.AspNetCore.Session\": \"1.1.0\"\r\n<\/pre>\n<p>To enable Redis in the application we need to add <em>AddDistributedCache<\/em> method in <em>ConfigureServices<\/em> method.<\/p>\n<pre>\r\npublic void ConfigureServices(IServiceCollection services)\r\n{\r\n    services.AddDistributedRedisCache(options =>\r\n    {\r\n        options.InstanceName = \"Sample\";\r\n        options.Configuration = \"localhost\";\r\n    });\r\n    services.AddMvc();\r\n}\r\n<\/pre>\n<p>To enable the session, we need to do changes in both <em>ConfigureServices<\/em> and <em>Configure<\/em>:<\/p>\n<pre>\r\npublic void ConfigureServices(IServiceCollection services)\r\n{\r\n    services.AddDistributedRedisCache(options =>\r\n    {\r\n        options.InstanceName = \"Sample\";\r\n        options.Configuration = \"localhost\";\r\n    });\r\n\r\n    services.AddSession();\r\n    services.AddMvc();\r\n}\r\n\r\npublic void Configure(IApplicationBuilder app, \r\n    IHostingEnvironment env, ILoggerFactory loggerFactory)\r\n{\r\n    app.UseSession();\r\n    app.UseMvc(routes =>\r\n    {\r\n        routes.MapRoute(\r\n            name: \"default\",\r\n            template: \"{controller=Home}\/{action=Index}\/{id?}\");\r\n    });\r\n}\r\n<\/pre>\n<h4>How do we access Redis?<\/h4>\n<p>To cache a value in Redis we use: <\/p>\n<pre>\r\nvar valueToStoreInRedis = Encoding.UTF8.GetBytes(\"This is a cached value from Redis\");\r\nHttpContext.Session.Set(\"TestProperty\", valueToStoreInRedis);\r\n<\/pre>\n<p>To retrieve the value from cache we use:<\/p>\n<pre>\r\nvar valueFromRedis = default(byte[]);\r\nif (HttpContext.Session.TryGetValue(\"TestProperty\", out valueFromRedis))\r\n    valueToDisplay = Encoding.UTF8.GetString(valueFromRedis);\r\n<\/pre>\n<h4>Twitter client example<\/h4>\n<p>External interfaces to connect to social platforms are usually relatively slow to access. If we would do a web application showing messages from Twitter, it would take a couple of seconds to load the page (to make the search and retrieve). If the same user would connect again to our application, Redis could retrieve from memory the same messages, without accessing the server again. Caching the results, and updating them only when new messages appear, bring a huge improvement to the overall performance.  <\/p>\n<p>To keep the things simple, I have earlier written a small client in Python, that connects to Twitter and save the details in a JSON file. You can read more details in the article <a href=\".\/vscode-twitter-python-json\/\" target=\"_blank\">Visual Studio Code \u2013 Connect to Twitter with Python<\/a>. It includes the full source code, and very fast you can access and save data in a JSON file.<\/p>\n<p>In our sample here, we start from an already available JSON file. <\/p>\n<pre>\r\n[\r\n {\r\n        \"Id\": 0,\r\n        \"ProfileImage\": \"https:\/\/pbs.twimg.com\/profile_images\/1772973596\/inogiclogo_normal.png\",\r\n        \"ProfileDescription\": \"Microsoft Partner with Gold Competency in #Dynamics365 #MSDynCRM providing Solns\/Services. Innovators of @Maplytics & Inolink #QuickBooks Int #MSDyn365 #MVPBuzz\",\r\n        \"Username\": \"Inogic\",\r\n        \"Text\": \"Execute the Global Action Using Web API in Dynamics CRM https:\/\/t.co\/DAuzP6L7FE #MSDyn365 #webapi https:\/\/t.co\/v0XgyotaFn\",\r\n        \"ScreenName\": \"@inogic\"\r\n    },\r\n    ....\r\n]\r\n<\/pre>\n<p>Retrieval of data from Twitter takes a couple of seconds. To simulate this, we add a delay of 20 seconds in our code. Here is the code from the controller. <\/p>\n<pre>\r\npublic IActionResult Index()\r\n{\r\n\tvar watch = Stopwatch.StartNew();\r\n\tstring jSONText = RetrieveOrUpdateRedis();\r\n\twatch.Stop();\r\n\r\n\tTempData[\"DataLoadTime\"] = watch.ElapsedMilliseconds;\r\n\tvar itemsFromjSON = JsonConvert.DeserializeObject<IEnumerable<TwitterItem>>(jSONText);\r\n\treturn View(itemsFromjSON);\r\n}\r\n\r\nprivate string RetrieveOrUpdateRedis()\r\n{\r\n\tvar valueFromRedis = default(byte[]);\r\n\tstring valueToReturn = string.Empty;\r\n\tif (HttpContext.Session.TryGetValue(\"TwitterDataset\", out valueFromRedis))\r\n\t{\r\n\t\t\/\/ Retrieve from Redis\r\n\t\tvalueToReturn = Encoding.UTF8.GetString(valueFromRedis);\r\n\t\tTempData[\"DataLoadType\"] = \"From Redis\";\r\n\t}\r\n\telse\r\n\t{\r\n\t\t\/\/ read the file and update the URLs\r\n\t\tvar jSONText = System.IO.File.ReadAllText(\"twitter.json\");\r\n\t\tvalueToReturn = GetUpdatedFileContent(jSONText);\r\n\r\n\t\t\/\/ add an artificial delay of 20 seconds (simulating the search is done directly against a Twitter server)\r\n\t\tThread.Sleep(20000);\r\n\r\n\t\t\/\/ store values in Redis\r\n\t\tvar valueToStoreInRedis = Encoding.UTF8.GetBytes(valueToReturn);\r\n\t\tHttpContext.Session.Set(\"TwitterDataset\", valueToStoreInRedis);\r\n\t\tTempData[\"DataLoadType\"] = \"From file\";\r\n\t}\r\n\r\n\treturn valueToReturn;\r\n}\r\n\r\n\/\/ a minimum data processing, updating the URLs\r\nprivate string GetUpdatedFileContent(string jSONText)\r\n{   \r\n\tvar itemsFromjSON = JsonConvert.DeserializeObject<IEnumerable<TwitterItem>>(jSONText);\r\n\tforeach (var item in itemsFromjSON)\r\n\t{\r\n\t\tRegex r = new Regex(@\"(https?:\/\/[^\\s]+)\");\r\n\t\titem.Text = r.Replace(item.Text, \"<a href=\\\"$1\\\">$1<\/a>\");\r\n\t}\r\n\r\n\treturn JsonConvert.SerializeObject(itemsFromjSON);\r\n}\r\n<\/pre>\n<h4>How fast does the application run with Redis?<\/h4>\n<p>The initial time to load is displayed below (this includes also the artificial timeout of 20 seconds):<br \/>\n<img src=\"data:image\/svg+xml,%3Csvg xmlns='http:\/\/www.w3.org\/2000\/svg' viewBox='0 0 677 343'%3E%3C\/svg%3E\" data-src=\"http:\/\/qappdesign.com\/wp-content\/uploads\/2016\/12\/No-Redis-Slow-1.jpg\" alt=\"\" class=\"alignnone wp-image-327 lazyload \" \/><noscript><img src=\"https:\/\/i0.wp.com\/qappdesign.com\/wp-content\/uploads\/2016\/12\/No-Redis-Slow-1.jpg?w=960\" alt=\"\" class=\"alignnone wp-image-327\" data-recalc-dims=\"1\" \/><\/noscript><\/p>\n<p>Just taking the results from Redis runs much faster. This exclude any &#8220;connection&#8221; to Twitter or any other internal update. Here is the print screen with the data retrieved from memory:<br \/>\n<img src=\"data:image\/svg+xml,%3Csvg xmlns='http:\/\/www.w3.org\/2000\/svg' viewBox='0 0 677 343'%3E%3C\/svg%3E\" data-src=\"http:\/\/qappdesign.com\/wp-content\/uploads\/2016\/12\/Faster-Access-With-Redis-1.jpg\" alt=\"\" class=\"alignnone wp-image-328 lazyload \" \/><noscript><img src=\"https:\/\/i0.wp.com\/qappdesign.com\/wp-content\/uploads\/2016\/12\/Faster-Access-With-Redis-1.jpg?w=960\" alt=\"\" class=\"alignnone wp-image-328\" data-recalc-dims=\"1\" \/><\/noscript><\/p>\n<p>To replicate this multiple times, and not just at the beginning, use command <em>flushall<\/em> to clean entire Redis cache:<\/p>\n<pre>\r\nC:\\Users\\[logged in user]\\.nuget\\packages\\Redis-64\\[version installed]\\tools>redis-cli.exe\r\n\r\n# in my case\r\nC:\\Users\\petru\\.nuget\\packages\\Redis-64\\3.0.503\\tools>redis-cli.exe\r\n\r\n# and then\r\n127.0.0.1:6379> flushall\r\n<\/pre>\n<h4>Is Redis just a cache? When to use it?<\/h4>\n<p>Redis is much more than just a cache. Like any cache, Redis stores indeed [key, value] pairs. More than this, Redis allows us to use values in a very efficient ways. Using different data structures (not just strings), we gain a lot of power (such as the ability to fine-tune cache contents and durability) and greater efficiency overall. Once we start using the data structures, the efficiency boost becomes tremendous for specific application scenarios.<\/p>\n<p>Here is a summary of the data structures, along with few concrete use cases associated with each type:<\/p>\n<div class=\"table-responsive\">\n<table class=\"table small-text table-condensed\">\n<thead>\n<tr>\n<th><\/th>\n<th>Uses<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<th>Strings<\/th>\n<td>Caches, counters, and clever bit-operations. <\/p>\n<p>          <strong>Session management<\/strong> is key to many<br \/>\n          online application. Their success depends by responsiveness and accuracy of data<br \/>\n          displayed, just to name here shopping carts for eCommerce websites. <strong>Distributed cache<\/strong>,<br \/>\n          it is a great alternative to the local cache.<\/td>\n<\/tr>\n<tr>\n<th>Lists<\/th>\n<td>Queues, stacks and cyclical lists. All these help to decouple processes, while receiving<br \/>\n          many new requests. <\/p>\n<p>          A simple example would be an web application that is used to place<br \/>\n          orders. The processing of the orders may take a while, and these<br \/>\n          could be <strong>decoupled using queues<\/strong>.<\/td>\n<\/tr>\n<tr>\n<th>Hashes<\/th>\n<td>These are field-value pairs, very efficient when storing many small values. <\/p>\n<p>          An example would be for implementing of a <strong>black lists<\/strong> checking feature.<br \/>\n          Or accessing very fast lots of images from a gallery.<br \/>\n    <\/tr>\n<tr>\n<th>Sets<\/th>\n<td>Are very good for expressing relations between objects. <\/p>\n<p>          These could make easy implementation of <strong>social tags<\/strong> in social networking<br \/>\n          applications, or discussion tags in blogs etc.<\/td>\n<\/tr>\n<tr>\n<th>Sorted Sets<\/th>\n<td>These are a mix between sets and Hashes. One example would be online games, where<br \/>\n          <strong>scoreboards<\/strong> and player statistics are vital.<\/td>\n<\/tr>\n<tr>\n<th>HyperLogLog<\/th>\n<td>Counting unique things. A simple use case, <strong>counting unique queries<\/strong><br \/>\n          performed by users in a search form during the day.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>What is Redis ? Redis is a super fast non-relational database that uses keys to map to different data types. It is a key value data store (NoSQL) allowing to solve efficiently many different problem sets. Redis was created by Salvatore Sanfilippo in 2009, and Sanfilippo still remains the lead developer of the project today. It is a mature and hugely popular open source project, being used by many companies and in countless mission-critical production environments. Here is an interview with the inventor of Redis, Salvatore Sanfilippo. Why is Redis popular? Not only is it extremely effective, but it is also relatively simple. Getting started with Redis is quite fast, and it usually takes only a few minutes to set up and get them working within an application. Thus, a small investment of time and effort can have an immediate, dramatic impact on performance of the application. Just to name two cases when Redis is helpful: Redis is used at Pinterest &#8211; see use case or at Twitter, where Raffi Kirkorian, VP of Engineering at Twitter, explains how Redis helps to support over 30 billion timeline updates per day based on 5000 tweets per second or 400,000,000 tweets per day [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true},"categories":[13,7,12,11],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v18.0 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Distributed cache using Redis and ASP.NET Core - Cloud, Data and Integrations<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/qappdesign.com\/code\/distributed-cache-using-redis-and-aspnet-core\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Distributed cache using Redis and ASP.NET Core - Cloud, Data and Integrations\" \/>\n<meta property=\"og:description\" content=\"What is Redis ? Redis is a super fast non-relational database that uses keys to map to different data types. It is a key value data store (NoSQL) allowing to solve efficiently many different problem sets. Redis was created by Salvatore Sanfilippo in 2009, and Sanfilippo still remains the lead developer of the project today. It is a mature and hugely popular open source project, being used by many companies and in countless mission-critical production environments. Here is an interview with the inventor of Redis, Salvatore Sanfilippo. Why is Redis popular? Not only is it extremely effective, but it is also relatively simple. Getting started with Redis is quite fast, and it usually takes only a few minutes to set up and get them working within an application. Thus, a small investment of time and effort can have an immediate, dramatic impact on performance of the application. Just to name two cases when Redis is helpful: Redis is used at Pinterest &#8211; see use case or at Twitter, where Raffi Kirkorian, VP of Engineering at Twitter, explains how Redis helps to support over 30 billion timeline updates per day based on 5000 tweets per second or 400,000,000 tweets per day [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/qappdesign.com\/code\/distributed-cache-using-redis-and-aspnet-core\/\" \/>\n<meta property=\"og:site_name\" content=\"Cloud, Data and Integrations\" \/>\n<meta property=\"article:published_time\" content=\"2016-12-21T05:00:38+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2017-03-03T09:08:19+00:00\" \/>\n<meta property=\"og:image\" content=\"http:\/\/qappdesign.com\/wp-content\/uploads\/2016\/12\/Redis-server.jpg\" \/>\n<meta name=\"twitter:card\" content=\"summary\" \/>\n<meta name=\"twitter:creator\" content=\"@qappdesign\" \/>\n<meta name=\"twitter:site\" content=\"@QAppDesign\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Petru Faurescu\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/qappdesign.com\/code\/#website\",\"url\":\"https:\/\/qappdesign.com\/code\/\",\"name\":\"QualityAppDesign\",\"description\":\"with Petru Faurescu\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/qappdesign.com\/code\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/qappdesign.com\/code\/distributed-cache-using-redis-and-aspnet-core\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"http:\/\/qappdesign.com\/wp-content\/uploads\/2016\/12\/Redis-server.jpg\",\"contentUrl\":\"http:\/\/qappdesign.com\/wp-content\/uploads\/2016\/12\/Redis-server.jpg\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/qappdesign.com\/code\/distributed-cache-using-redis-and-aspnet-core\/#webpage\",\"url\":\"https:\/\/qappdesign.com\/code\/distributed-cache-using-redis-and-aspnet-core\/\",\"name\":\"Distributed cache using Redis and ASP.NET Core - Cloud, Data and Integrations\",\"isPartOf\":{\"@id\":\"https:\/\/qappdesign.com\/code\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/qappdesign.com\/code\/distributed-cache-using-redis-and-aspnet-core\/#primaryimage\"},\"datePublished\":\"2016-12-21T05:00:38+00:00\",\"dateModified\":\"2017-03-03T09:08:19+00:00\",\"author\":{\"@id\":\"https:\/\/qappdesign.com\/code\/#\/schema\/person\/54db90dc6fe846cfd4c5a9544d93b75a\"},\"breadcrumb\":{\"@id\":\"https:\/\/qappdesign.com\/code\/distributed-cache-using-redis-and-aspnet-core\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/qappdesign.com\/code\/distributed-cache-using-redis-and-aspnet-core\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/qappdesign.com\/code\/distributed-cache-using-redis-and-aspnet-core\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/qappdesign.com\/code\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Distributed cache using Redis and ASP.NET Core\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/qappdesign.com\/code\/#\/schema\/person\/54db90dc6fe846cfd4c5a9544d93b75a\",\"name\":\"Petru Faurescu\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/qappdesign.com\/code\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/84fb359a4e3d583dbea5a34bd5566956?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/84fb359a4e3d583dbea5a34bd5566956?s=96&d=mm&r=g\",\"caption\":\"Petru Faurescu\"},\"description\":\"Product lead, software developer &amp; architect\",\"sameAs\":[\"https:\/\/qappdesign.com\/code\",\"https:\/\/www.linkedin.com\/in\/petrufaurescu\/\",\"https:\/\/twitter.com\/@qappdesign\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Distributed cache using Redis and ASP.NET Core - Cloud, Data and Integrations","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/qappdesign.com\/code\/distributed-cache-using-redis-and-aspnet-core\/","og_locale":"en_US","og_type":"article","og_title":"Distributed cache using Redis and ASP.NET Core - Cloud, Data and Integrations","og_description":"What is Redis ? Redis is a super fast non-relational database that uses keys to map to different data types. It is a key value data store (NoSQL) allowing to solve efficiently many different problem sets. Redis was created by Salvatore Sanfilippo in 2009, and Sanfilippo still remains the lead developer of the project today. It is a mature and hugely popular open source project, being used by many companies and in countless mission-critical production environments. Here is an interview with the inventor of Redis, Salvatore Sanfilippo. Why is Redis popular? Not only is it extremely effective, but it is also relatively simple. Getting started with Redis is quite fast, and it usually takes only a few minutes to set up and get them working within an application. Thus, a small investment of time and effort can have an immediate, dramatic impact on performance of the application. Just to name two cases when Redis is helpful: Redis is used at Pinterest &#8211; see use case or at Twitter, where Raffi Kirkorian, VP of Engineering at Twitter, explains how Redis helps to support over 30 billion timeline updates per day based on 5000 tweets per second or 400,000,000 tweets per day [&hellip;]","og_url":"https:\/\/qappdesign.com\/code\/distributed-cache-using-redis-and-aspnet-core\/","og_site_name":"Cloud, Data and Integrations","article_published_time":"2016-12-21T05:00:38+00:00","article_modified_time":"2017-03-03T09:08:19+00:00","og_image":[{"url":"http:\/\/qappdesign.com\/wp-content\/uploads\/2016\/12\/Redis-server.jpg"}],"twitter_card":"summary","twitter_creator":"@qappdesign","twitter_site":"@QAppDesign","twitter_misc":{"Written by":"Petru Faurescu","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/qappdesign.com\/code\/#website","url":"https:\/\/qappdesign.com\/code\/","name":"QualityAppDesign","description":"with Petru Faurescu","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/qappdesign.com\/code\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https:\/\/qappdesign.com\/code\/distributed-cache-using-redis-and-aspnet-core\/#primaryimage","inLanguage":"en-US","url":"http:\/\/qappdesign.com\/wp-content\/uploads\/2016\/12\/Redis-server.jpg","contentUrl":"http:\/\/qappdesign.com\/wp-content\/uploads\/2016\/12\/Redis-server.jpg"},{"@type":"WebPage","@id":"https:\/\/qappdesign.com\/code\/distributed-cache-using-redis-and-aspnet-core\/#webpage","url":"https:\/\/qappdesign.com\/code\/distributed-cache-using-redis-and-aspnet-core\/","name":"Distributed cache using Redis and ASP.NET Core - Cloud, Data and Integrations","isPartOf":{"@id":"https:\/\/qappdesign.com\/code\/#website"},"primaryImageOfPage":{"@id":"https:\/\/qappdesign.com\/code\/distributed-cache-using-redis-and-aspnet-core\/#primaryimage"},"datePublished":"2016-12-21T05:00:38+00:00","dateModified":"2017-03-03T09:08:19+00:00","author":{"@id":"https:\/\/qappdesign.com\/code\/#\/schema\/person\/54db90dc6fe846cfd4c5a9544d93b75a"},"breadcrumb":{"@id":"https:\/\/qappdesign.com\/code\/distributed-cache-using-redis-and-aspnet-core\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/qappdesign.com\/code\/distributed-cache-using-redis-and-aspnet-core\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/qappdesign.com\/code\/distributed-cache-using-redis-and-aspnet-core\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/qappdesign.com\/code\/"},{"@type":"ListItem","position":2,"name":"Distributed cache using Redis and ASP.NET Core"}]},{"@type":"Person","@id":"https:\/\/qappdesign.com\/code\/#\/schema\/person\/54db90dc6fe846cfd4c5a9544d93b75a","name":"Petru Faurescu","image":{"@type":"ImageObject","@id":"https:\/\/qappdesign.com\/code\/#personlogo","inLanguage":"en-US","url":"https:\/\/secure.gravatar.com\/avatar\/84fb359a4e3d583dbea5a34bd5566956?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/84fb359a4e3d583dbea5a34bd5566956?s=96&d=mm&r=g","caption":"Petru Faurescu"},"description":"Product lead, software developer &amp; architect","sameAs":["https:\/\/qappdesign.com\/code","https:\/\/www.linkedin.com\/in\/petrufaurescu\/","https:\/\/twitter.com\/@qappdesign"]}]}},"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p82xvM-3y","_links":{"self":[{"href":"https:\/\/qappdesign.com\/code\/wp-json\/wp\/v2\/posts\/220"}],"collection":[{"href":"https:\/\/qappdesign.com\/code\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/qappdesign.com\/code\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/qappdesign.com\/code\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/qappdesign.com\/code\/wp-json\/wp\/v2\/comments?post=220"}],"version-history":[{"count":72,"href":"https:\/\/qappdesign.com\/code\/wp-json\/wp\/v2\/posts\/220\/revisions"}],"predecessor-version":[{"id":569,"href":"https:\/\/qappdesign.com\/code\/wp-json\/wp\/v2\/posts\/220\/revisions\/569"}],"wp:attachment":[{"href":"https:\/\/qappdesign.com\/code\/wp-json\/wp\/v2\/media?parent=220"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/qappdesign.com\/code\/wp-json\/wp\/v2\/categories?post=220"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/qappdesign.com\/code\/wp-json\/wp\/v2\/tags?post=220"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}