diff --git a/docs/en/Caching.md b/docs/en/Caching.md index 378e5885e6..8aa9f00657 100644 --- a/docs/en/Caching.md +++ b/docs/en/Caching.md @@ -19,7 +19,7 @@ See [ASP.NET Core's distributed caching document](https://docs.microsoft.com/en- ## `IDistributedCache` Interface -ABP framework defines the generic `IDistributedCache` interface in the [Volo.Abp.Caching](https://www.nuget.org/packages/Volo.Abp.Caching/) package. `TCacheItem` is the type of the object stored in the cache. +ABP framework defines the generic `IDistributedCache` interface in the [Volo.Abp.Caching](https://www.nuget.org/packages/Volo.Abp.Caching/) package. `TCacheItem` is the type of the object stored in the cache. `IDistributedCache` solves the difficulties explained above; @@ -80,6 +80,93 @@ public class BookService : ITransientDependency Other methods of the `IDistributedCache` are same as ASP.NET Core's `IDistributedCache` interface, so you can refer [it's documentation](https://docs.microsoft.com/en-us/aspnet/core/performance/caching/distributed). +## `IDistributedCache` Interface + +`IDistributedCache` interface assumes that the type of your cache key is `string` (so, you need to manually convert your key to string if you need to use a different kind of cache key). `IDistributedCache` can be used when your cache key type is not `string`. + +### Usage + +An example class to store an item in the cache: + +````csharp +public class BookCacheItem +{ + public string Name { get; set; } + + public float Price { get; set; } +} +```` + +Example usage (assumes that your cache key type is `Guid`): + +````csharp +public class BookService : ITransientDependency +{ + private readonly IDistributedCache _cache; + + public BookService(IDistributedCache cache) + { + _cache = cache; + } + + public async Task GetAsync(Guid bookId) + { + return await _cache.GetOrAddAsync( + bookId, //Guid type used as the cache key + async () => await GetBookFromDatabaseAsync(bookId), + () => new DistributedCacheEntryOptions + { + AbsoluteExpiration = DateTimeOffset.Now.AddHours(1) + } + ); + } + private Task GetBookFromDatabaseAsync(Guid bookId) + { + //TODO: get from database + } +} +```` + +* This sample service uses the `GetOrAddAsync()` method to get a book item from the cache. +* Since cache explicitly implemented as using `Guid` as cache key, `Guid` value passed to `_cache_GetOrAddAsync()` method. + +`IDistributedCache` internally uses `ToString()` method of the key object to convert it to a string. If you need to use a complex object as the cache key, you need to override `ToString` method of your class. + +An example class that is used as a cache key: + +````csharp +public class UserInOrganizationCacheKey +{ + public Guid UserId { get; set; } + + public Guid OrganizationId { get; set; } + + //Builds the cache key + public override string ToString() + { + return $"{UserId}_{OrganizationId}"; + } +} +```` + +Example usage: + +````csharp +public class BookService : ITransientDependency +{ + private readonly IDistributedCache _cache; + + public BookService( + IDistributedCache cache) + { + _cache = cache; + } + + ... +} +```` + ### DistributedCacheOptions TODO + diff --git a/docs/en/Index.md b/docs/en/Index.md index b40efffb9d..48935d70c3 100644 --- a/docs/en/Index.md +++ b/docs/en/Index.md @@ -4,18 +4,12 @@ ABP is an **open source application framework** focused on ASP.NET Core based we Explore the left navigation menu to deep dive in the documentation. -## Project Status - -ABP is the **next generation** of the open source [ASP.NET Boilerplate](https://aspnetboilerplate.com/) framework. It's currently in preview stage and not ready to use in production. The documentation is still in progress and it is far from complete. - -For short-term and production level applications, it's suggested to use [ASP.NET Boilerplate](https://aspnetboilerplate.com/) framework which has rich feature set, mature, actively maintained and up-to-date. - ## Getting Started Easiest way to start a new project with ABP is to use the startup templates: -* [ASP.NET Core MVC (Razor Pages) UI Template](Getting-Started-AspNetCore-MVC-Template.md) -* [Angular UI Template](Getting-Started-Angular-Template.md) +* [ASP.NET Core MVC (Razor Pages) UI Startup Template](Getting-Started-AspNetCore-MVC-Template.md) +* [Angular UI Startup Template](Getting-Started-Angular-Template.md) If you want to start from scratch (with an empty project) then manually install the ABP Framework and use the following tutorials: diff --git a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs index 2a1f109f5c..4140cceeb3 100644 --- a/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs +++ b/framework/src/Volo.Abp.Caching/Volo/Abp/Caching/DistributedCache.cs @@ -19,13 +19,11 @@ namespace Volo.Abp.Caching where TCacheItem : class { public DistributedCache( - IOptions cacheOption, - IOptions distributedCacheOption, + IOptions distributedCacheOption, IDistributedCache cache, ICancellationTokenProvider cancellationTokenProvider, IDistributedCacheSerializer serializer, ICurrentTenant currentTenant) : base( - cacheOption: cacheOption, distributedCacheOption: distributedCacheOption, cache: cache, cancellationTokenProvider: cancellationTokenProvider, @@ -62,12 +60,9 @@ namespace Volo.Abp.Caching protected DistributedCacheEntryOptions DefaultCacheOptions; - private readonly AbpDistributedCacheOptions _cacheOption; - private readonly AbpDistributedCacheOptions _distributedCacheOption; public DistributedCache( - IOptions cacheOption, IOptions distributedCacheOption, IDistributedCache cache, ICancellationTokenProvider cancellationTokenProvider, @@ -75,7 +70,6 @@ namespace Volo.Abp.Caching ICurrentTenant currentTenant) { _distributedCacheOption = distributedCacheOption.Value; - _cacheOption = cacheOption.Value; Cache = cache; CancellationTokenProvider = cancellationTokenProvider; Logger = NullLogger>.Instance; @@ -88,7 +82,7 @@ namespace Volo.Abp.Caching } protected virtual string NormalizeKey(TCacheKey key) { - var normalizedKey = "c:" + CacheName + ",k:" + _cacheOption.KeyPrefix + key.ToString(); + var normalizedKey = "c:" + CacheName + ",k:" + _distributedCacheOption.KeyPrefix + key.ToString(); if (!IgnoreMultiTenancy && CurrentTenant.Id.HasValue) { @@ -100,7 +94,7 @@ namespace Volo.Abp.Caching protected virtual DistributedCacheEntryOptions GetDefaultCacheEntryOptions() { - foreach (var configure in _cacheOption.CacheConfigurators) + foreach (var configure in _distributedCacheOption.CacheConfigurators) { var options = configure.Invoke(CacheName); if (options != null) @@ -108,7 +102,7 @@ namespace Volo.Abp.Caching return options; } } - return _cacheOption.GlobalCacheEntryOptions; + return _distributedCacheOption.GlobalCacheEntryOptions; } protected virtual void SetDefaultOptions() diff --git a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json index f5167f51f2..bc507158b1 100644 --- a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json +++ b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/en.json @@ -14,6 +14,8 @@ "Login": "Login", "Cancel": "Cancel", "Register": "Register", + "AreYouANewUser": "Are you a new user?", + "AlreadyRegistered": "Already registered?", "InvalidLoginRequest": "Invalid login request", "ThereAreNoLoginSchemesConfiguredForThisClient": "There are no login schemes configured for this client.", "LogInUsingYourProviderAccount": "Log in using your {0} account", diff --git a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/zh-Hans.json b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/zh-Hans.json index 6aee740de6..cc616961f1 100644 --- a/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/zh-Hans.json +++ b/modules/account/src/Volo.Abp.Account.Application.Contracts/Volo/Abp/Account/Localization/Resources/zh-Hans.json @@ -14,6 +14,8 @@ "Login": "登录", "Cancel": "取消", "Register": "注册", + "AreYouANewUser": "你是新用户吗?", + "AlreadyRegistered": "已经注册过了?", "InvalidLoginRequest": "登录请求无效", "ThereAreNoLoginSchemesConfiguredForThisClient": "没有为此客户端配置登录方案.", "LogInUsingYourProviderAccount": "使用你的{0}帐户登录" diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml index 1703042d42..cba1fec431 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Login.cshtml @@ -11,7 +11,7 @@ @if (string.Equals(await SettingProvider.GetOrNullAsync(AccountSettingNames.IsSelfRegistrationEnabled), "true", StringComparison.OrdinalIgnoreCase)) { - Are you new user? + @L["AreYouANewUser"] @L["Register"] } diff --git a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml index 7b6f090d7f..44d352153c 100644 --- a/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml +++ b/modules/account/src/Volo.Abp.Account.Web/Pages/Account/Register.cshtml @@ -6,7 +6,7 @@

@L["Register"]

- Already registered? + @L["AlreadyRegistered"] @L["Login"]
diff --git a/npm/packs/core/src/abp.css b/npm/packs/core/src/abp.css index 1d3af876c7..8d2de280ce 100644 --- a/npm/packs/core/src/abp.css +++ b/npm/packs/core/src/abp.css @@ -14,7 +14,7 @@ left: 0; width: 100%; height: 100%; - z-index: 999999999; + z-index: 102; background-color: #fff; opacity: .8; transition: opacity .25s;