Friday, 15 January 2016

ASP.NET Tips #71 - Use caching to reduce load on the database

Accessing the database is often the slowest aspect of an application due to the physical nature of accessing the data from disk (database query caching not withstanding). Developing your application with an efficient caching mechanism in mind can relieve the need for your database to perform requests and let it devote its time where required.

Simple things like caching reference data or data that changes very infrequently can make easy gains and reduce load on your database. As you cache more and more, it's important to ensure you invalidate cached data when it is updated using a common key, and this needs to be factored into the design.

For a headstart on caching and supporting multiple cache engines easily, try this library https://bitbucket.org/glav/cacheadapter. This allows you to support ASP.NET web cache,memcached, Redis and the now defunct AppFabric on the same codebase via configuration only.

No comments :

Post a comment