PolyCache is a powerful distributed cache manager package designed specifically for .Net Core projects. It allows you to efficiently manage and store cached data, enhancing the performance of your applications. If you find PolyCache helpful for your project or learning experience, consider giving it a star ⭐. Your support is appreciated!
To get started with PolyCache, you can easily install it via NuGet Package Manager:
> Install-Package PolyCache
To use PolyCache, you need to register it in your application's Startup class by adding the following code to the ConfigureServices
method:
services.AddPolyCache(Configuration);
PolyCache provides various options for configuring your distributed cache. You can choose from the following cache types:
- Redis
- Memory
- SQL Server
Select the cache implementation you want to use from the available options.
This setting is only required when using SQL Server as your cache storage.
Specify the SQL Server database table name where your cache data will be stored.
To configure these options, add the following configuration to your appsettings.json
file:
"CacheConfig": {
"DefaultCacheTime": 60,
"ShortTermCacheTime": 3,
"BundledFilesCacheTime": 120
},
"DistributedCacheConfig": {
"DistributedCacheType": "redis",
"Enabled": true,
"ConnectionString": "127.0.0.1:6379,ssl=False",
"SchemaName": "dbo",
"TableName": "DistributedCache"
}
Once you've configured PolyCache, you can inject the IStaticCacheManager
interface into your application and use it to cache data efficiently. A sample project that demonstrates the usage of PolyCache is available in our GitHub repository.
If you plan to use Redis as your cache storage, follow these steps to set it up with Docker Compose:
-
Install Docker on your operating system.
-
Download the
redis-docker-compose.yml
file from the sample project and place it in a convenient directory on your system. -
Open your terminal as an administrator.
-
Navigate to the directory where you placed the
redis-docker-compose.yml
file. -
Run the following command to start Redis in a Docker container:
docker-compose -f redis-docker-compose.yml up
-
Redis is now ready to use within your Docker environment.
Enjoy the benefits of PolyCache in your .Net Core projects and optimize your application's performance with ease!