注意:请牢记分区和索引编制的问题。
如果我们观察IdentityServer4的IPersistedGrantStore的方法,我们可以知道我们应该能够分别使用'key'和'subjectId'来获取数据。
表存储 :由于以下原因,我尝试放弃使用表存储的想法:
Cosmos DB SQL API :Cosmos DB支持所有属性的索引并支持TTL(出色)..但是问题在于分区。
单个逻辑分区的存储上限为10 GB。 因此,我们需要使用“ key”或“ subject id”进行分区。 如果将“键”用于分区,则需要“主题ID”的查询 进行完整的数据库扫描,反之亦然。
public class IPersistedGrantStor {
Task<PersistedGrant> GetAsync(string key);
Task<IEnumerable<PersistedGrant>> GetAllAsync(string subjectId);
Task RemoveAsync(string key);
Task RemoveAllAsync(string subjectId, string clientId);
Task RemoveAllAsync(string subjectId, string clientId, string type);
}
是否有一种正确的方法来对持久授权存储库数据进行分区,从而避免对getByKey和getBySubjectID进行完整的数据库扫描?
还是使用SQL DB?