It says Redis is required in the documentation. Why do we need to install Redis for ABP? If we don't install it, what happens?
1 Answer(s)
-
0
As a summary
- If you deploy your application as multiple instances, you need a distributed cache, like Redis.
- If you have multiple applications (like a microservice or distributed solution) that need to share the same cache objects, you need to have a distributed cache, like Redis.
- ABP's default cache is In-Memory Cache. It is usable only if you have a single application with a single instance running on a single server. Even in that scenario, it's good to use Redis because your cached objects are not erased when the application restarts.
What's Redis?
Redis (REmote DIctionary Server). This open-source application provides in-memory caching. It is known for its high-performance capabilities.
It’s very fast for reading/writing data. That’s why we use Redis for distributed cache in the following projects
Where is Redis being used in ABP projects?
- AuthServer https://github.com/abpframework/abp/blob/dev/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.AuthServer/appsettings.json
- DbMigrator https://github.com/abpframework/abp/blob/dev/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.DbMigrator/appsettings.json
- Web.Host https://github.com/abpframework/abp/blob/dev/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Web.Host/appsettings.json
- HttpApi.Host https://github.com/abpframework/abp/blob/dev/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.HttpApi.Host/appsettings.json
- Blazor.Server.Tiered https://github.com/abpframework/abp/blob/dev/templates/app/aspnet-core/src/MyCompanyName.MyProjectName.Blazor.Server.Tiered/appsettings.json
Why must we use Redis in ABP projects?
You only need to install Redis for the
n-tierarchitecture where Web and HTTP API layers are physically separated. If you work on ann-layeredsolution with no HTTP API project, then you don't need Redis.You can see in which cases Redis is pre-required from the documentation page: docs.abp.io/en/abp/latest/Getting-Started-Setup-Environment?UI=MVC&DB=EF&Tiered=Yes
What exactly is being cached in Redis?
When you see the
IDistributedCacheinterface, it means Redis is required by default. The following modules are already using Redis (some modules are commercial modules):- setting-management:
SettingManagementStorefor setting values. - permission-management:
PermissionStorefor granted permissions. - saas:
TenantDeletedHandlerand TenantStore class - cms-kit:
UrlShortingPublicAppServiceclass for Shortened URL Caches - language-management: DynamicResourceLocalizer class for the Language Text caches
- file-management:
FileDescriptorAppServiceclass for the Download Token Cache. - text-template-management:
DynamicTemplateDefinitionStoreclass - gdpr:
GdprRequestAppServiceclass for Download Token Cache.
- setting-management:
Finally, I want you to know that you can replace Redis with any other caching provider like Memcached.
Resources:
