Class SentryPreferenceCache
Caches preferences in the "Rights-*" section. Cache is manually flushed when SoPreference sets a "Rights-" preference value, or every 10 minutes.
Inherited Members
Namespace: SuperOffice.CRM.Security
Assembly: SoDataBase.dll
Syntax
[CacheV2(0)]
public class SentryPreferenceCache : CacheBaseV2
Constructors
SentryPreferenceCache()
Caches preferences in the "Rights-*" section. Cache is manually flushed when SoPreference sets a "Rights-" preference value, or every 10 minutes.
Declaration
public SentryPreferenceCache()
Properties
TableNames
Caches preferences in the "Rights-*" section. Cache is manually flushed when SoPreference sets a "Rights-" preference value, or every 10 minutes.
Declaration
protected override IEnumerable<string> TableNames { get; }
Property Value
Type | Description |
---|---|
IEnumerable<string> |
Overrides
Remarks
Although we read from table "UserPreference" we shouldn't add it to TableNames for this cache because there's too much traffic on that table. Invoking flush on every table change would be expensive, so we implement a custom IsCacheInvalidated to only trigger when it sees Rights-* changes or updates to known sentry preferences.
Methods
GetFieldRights(int, int, int)
Get the field rights from the preference system for a user.
Declaration
public FieldRight GetFieldRights(int sentryTable, int fieldId, int rowId)
Parameters
Type | Name | Description |
---|---|---|
int | sentryTable | TableNumber for the main sentry table. |
int | fieldId | FieldNumber (TableNumber [left shift] 8 + FieldNumber) for the field to look up |
int | rowId | Primary key of the row. 0 if the row is new. |
Returns
Type | Description |
---|---|
FieldRight | Field rights from the preference system. |
GetFieldRights(int, int, int, int, int)
Get the field rights from the preference system for a user.
Declaration
public FieldRight GetFieldRights(int sentryTable, int fieldId, int associateId, int groupId, int rowId)
Parameters
Type | Name | Description |
---|---|---|
int | sentryTable | TableNumber for the main sentry table. |
int | fieldId | FieldNumber (TableNumber [left shift] 8 + FieldNumber) for the field to look up |
int | associateId | AssociateId for the user to get the rights for. |
int | groupId | Group id for the user to get the rights for |
int | rowId | Primary key of the row. 0 if the row is new. |
Returns
Type | Description |
---|---|
FieldRight | Field rights from the preference system. |
GetFieldRights(int, int, int, ClaimsPrincipal)
Get the field rights from the preference system for a user.
Declaration
public FieldRight GetFieldRights(int sentryTable, int fieldId, int rowId, ClaimsPrincipal principal)
Parameters
Type | Name | Description |
---|---|---|
int | sentryTable | TableNumber for the main sentry table. |
int | fieldId | FieldNumber (TableNumber [left shift] 8 + FieldNumber) for the field to look up |
int | rowId | Primary key of the row. 0 if the row is new. |
ClaimsPrincipal | principal | Providing the princpial for optimization |
Returns
Type | Description |
---|---|
FieldRight | Field rights from the preference system. |
GetTableRights(int, int)
Get table rights from the preference system for the logged in user.
Declaration
public TableRight GetTableRights(int sentryTable, int rowId)
Parameters
Type | Name | Description |
---|---|---|
int | sentryTable | TableNumber for the main sentry table. |
int | rowId | Primary key of the row. 0 if the row is new. |
Returns
Type | Description |
---|---|
TableRight | Table rights from the preference system. |
GetTableRights(int, int, int, int)
Get table rights from the preference system for a user.
Declaration
public TableRight GetTableRights(int sentryTable, int associateId, int groupId, int rowId)
Parameters
Type | Name | Description |
---|---|---|
int | sentryTable | TableNumber for the main sentry table. |
int | associateId | AssociateId for the user to get the rights for. |
int | groupId | Group id for the user to get the rights for |
int | rowId | Primary key of the row. 0 if the row is new. |
Returns
Type | Description |
---|---|
TableRight | Table rights from the preference system. |
IsCacheInvalidatedAsync(string, int, PrivateSave, CancellationToken)
Determine if cache was actually invalidated by this change - much of the traffic on the userpreference table does not affect us here
Declaration
protected override Task<bool> IsCacheInvalidatedAsync(string tableName, int primaryKey, PrivateSave save, CancellationToken cancellationToken = default)
Parameters
Type | Name | Description |
---|---|---|
string | tableName | |
int | primaryKey | |
PrivateSave | save | |
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task<bool> |
Overrides
Remarks
This cache is invalidated if one of the previously known rows is deleted, OR if a row with a section name starting with Rights- is created or updated.
OnLoad()
Caches preferences in the "Rights-*" section. Cache is manually flushed when SoPreference sets a "Rights-" preference value, or every 10 minutes.
Declaration
protected override void OnLoad()
Overrides
OnLoadAsync(CancellationToken)
Caches preferences in the "Rights-*" section. Cache is manually flushed when SoPreference sets a "Rights-" preference value, or every 10 minutes.
Declaration
[CreateSyncVersion(OmitNullableDirective = true)]
protected override Task OnLoadAsync(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken |
Returns
Type | Description |
---|---|
Task |