Tag Archives: ASP.NET

In-Memory Caching (ASP.NET Core)

Know About In-Memory Caching (ASP.NET Core)

By: | , , | August 14, 2018

Some of the things to grasp concerning In-Memory Caching in ASP.NET Core

The main purpose of caching mechanism is to boost the performance of an application. ASP.NET web forms technology, as well as ASP.NET MVC technology, could use server aspect information caching and was offered as an integral feature of the .NET framework. In ASP.NET Core we do not have cache object, you’ll implement in-memory caching quite simply.

  • Enable caching within the Startup.cs

ASP.NET Core doesn’t have the integral Cache object that you just will directly use within controllers as like ASP.NET internet forms and ASP.NET MVC. In-memory caching works through dependency injection and thus the primary step is to register the in-memory caching service within the Startup.cs.

So, open the Startup.cs class file and modify the ConfigureServices() method by adding AddMemoryCache().

To add in-memory caching to your application you would like to call AddMemoryCache() function on the services assortment. By this fashion, the default implementation of in-memory cache is injected to the controllers.

  • Uses of dependency injection to inject the cache object

For that go to Controller and declares a non-public variable of IMemoryCache. This variable gets appointed within the constructor. The constructor will receive the cache parameter through dependency injection then this cache object is kept within the native variable for later use.

  • Set() method to save an item in the cache

As and when you got IMemoryCache object, you can get and set values into the cache object.

Let’s sets a value to the cache in action method by using the cache.Set<string>(“username”, “admin”); the primary parameter of Set() method is the key name and that key we can use it for fetching the value from cache. The second parameter is that the value of the key.

  • Get() method to fetch data that stored in the cache

As and when you stored value the cache, you can be fetched it anywhere in the application by using Get() method and can display in view or do any kind of operation on it. For example. string username = cache.Get<string>(“username”);

  • Use of GetOrCreate() method

By using the cache.GetOrCreate() you can check whether the passed key exists or not and if it does not exist then will create new cache key value.

Ex. cache.GetOrCreate()<string>(“username”, entry => { return “admin”; });

  • Use of TryGetValue() to check whether the key exists or not

By using the cache.TryGetValue() we can check whether the key exists or not. Here the main difference between cache.GetOrCreate() and cache.TryGetValue() method is that TryGet() method will only check whether the key exists or not whereas GetOrCreate() method will cache whether the key exists or not and if it doesn’t exist then can create a new one.

Syntax for TryGet() method is as below:

cache.TryGetValue()<string>(“username”, out string username);

  • Set priority for cache

Similarly, as you can set the lapse arrangements of a reserved thing you can assign a priority value to a cached item. On the off chance that server encounters lack of memory in view of this need the things will be evacuated to recover the memory. To set the need you utilize MemoryCacheEntryOptions once more.

Apart from all above you can set a dependency between multiple cached items, set absolute and sliding expiration and also wire a callback when an item is removed from the cache.


All You Would like to Know About – Overview and Advantage of .Net Technology

By: | , , , | February 27, 2018

Overview of .NET Framework

The .NET framework is software that is intended by the Microsoft. It runs totally on Microsoft Windows. It provides the language ability across many programming languages. The framework strives to offer a highly consistent object oriented programming environment. It can be used to create apps that run on multiple platforms. In short, these are desktop, mobile, as well as web apps that run on Windows-based devices, PCs, and servers it additionally includes the massive category library referred to as Framework category Library (FCL). These programs will run in software system atmosphere referred to as the Common Language Runtime (CLR). An interesting side of this framework is that it supports the creation of cross platform server apps that may swimmingly run across server platforms as Linux, Windows, and even mac. This Asp.Net Development framework can be utilized to configuration, designing & development, compilation, build program, create, incorporate, form, and deploy, send an application with its wide scope of help programs, code libraries, compilers, and APIs.

ASP.NET has been utilize by many wide range of developers for the developing web or window app and services on different devices and operating system. Here is its consistent developer expertise whereas building a variety of different applications. Another important think that need here is its consistent developer expertise whereas building a variety of various apps.

Advantages of .NET Technology

  • Everything that you just see within the .NET framework is an object. It’s the same for what you write within the framework. This implies that you simply get a powerful tool to not just access but also control your apps.
  • We can simply maintain our application because of separation of concern.
  • In the same time we are able to split several developers work at a time. It won’t affect one developer work to another developer work.
  • It supports TTD (test-driven development). We are able to produce an application with unit test. We are able to write won test case.
  • Latest version of MVC Support default responsive website and mobile templates.
  • We can diminish large part of coding and save lots of time of developers because of the development method of .NET.
  • .NET additionally remains for its program checking. It will promptly see any issues like infinite loops, memory spills, and so on. Not only this, it will likewise demolish these activities automatically and restart itself.

Project Training

Countries We Serve

  • India
  • UK (United Kingdom)
  • USA
  • Canada
  • Sweden
  • Australia
  • South Africa
  • New Zealand
  • Singapore
  • Europe
  • Italy
  • France
  • Denmark
  • Germany
  • Israel
  • Saudi Arabia
  • Kuwait
  • United Arab Emirates
  • Qatar
  • Bahrain