Skip to content

Fallbacks, automatic/general invalidation, Redis Optimizations, IScopedCache #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

AwMalka
Copy link
Contributor

@AwMalka AwMalka commented Jan 23, 2020

RedisNotifier

  • new policy option: GeneralInvalidationChannel to support invalidation requests by external orchestrator

InMemory

  • new policy option: OnSyncProviderFailure to enable
  1. Fallback expiry policy
  2. Automatic Invalidation on connection state change

LayeredCache

  • new policy option: InvalidateLevel1OnLevel2Update
    whenever Level2.Set is invoked (including Get(key, getter))
    automatically publish CacheItemActionTypes.Updated

RedisClient

  • Reuse multiplex connections by name instead of creating new connections per cache manager
  • Invalid AbsoluteExpiration handling bug fix

3 new cache types: that relies on the new CacheDirectives

  • InMemoryScopedCache
  • RedisScopedCache
  • LayeredScopedCache

CacheableActionFilterAttribute (WebApiExtended/WebApiExtended.NETCore)
for automatically setting CacheDirectives on scope web api actions

Using the new CacheDirectives, the consumer is able to effect cache method used (None/Get/Set/GetOrSet) and to specify the acceptable response age based on its own specific BL (using MinimumValueTimestamp)

Use cases for example:
Service A provides CustomerDetails

Service B needs CustomerDetails.RegistrationDate which doesn't change over time so cache result is always accepted
Service C has a BL which can accept CustomerDetails retrieved in the last 30 minutes
Service D has a BL which can accept CustomerDetails retrieved at least after a specific timestamp
Service E BL requires up-to-date CustomerDetails (no-cache)

by using CacheableActionFilterAttribute and *ScopedCache defined with slidingExpiration of 30 minutes we can serve all listed above easily and safely using a single endpoint in Service A

as a bonus, it makes it easier to retrieve data from replicated datasources while taking into consideration replication lags by relying on ValueTimestamp/MinimumValueTimestamp and GetScoped/SetScoped added functionalities

Copy link
Contributor Author

@AwMalka AwMalka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Danny,

I had a design review and partial code review by Roni and his team
and Zoar reviewed the unit tests

I've made some changes per your request, please check again and let me know what you think.

Thanks,
Avi

@AwMalka AwMalka requested a review from DannyVarod January 24, 2020 08:48
Avi Malka added 15 commits January 27, 2020 14:22
-	Warning on invalid input in headers
o	In addition, now demoting to CacheMethod.None instead of just removing CacheMethod.Get
-	Rename – InvalidateLevel1OnLevel2Update  InvalidateLevel1OnLevel2Upsert
o	Fix – LayeredScopedCache constructor regarding level1notifier initialization (copy fix from LayeredCache)
-	Add IgnoreMinimumValueTimestamp (0b_0001_0000)  to CacheMethod 
-	Change GeneralInvalidation channel message to be used as CacheName Regex (.* for all, sc(\d*)_notificationHub_.+ for all NotificationHubDomain, …)
-	Swagger helper for Core
-	Some refactoring (IsValid, IsInScope, …)
SyncProvider Failure Policy and LayeredScoped TryGet
@amitla
Copy link
Collaborator

amitla commented Feb 11, 2020

@AwMalka Adding to a public interface is effectively a breaking change (one interface changed for instance is ICacheNotifier). We need to reflect this in the version - it should be version 5.0.0

I'm still going through the changes, but in general - anywhere you have a change to a public interface (and/or class for that mater) - update major version (version, file version and assembly version).

If there are no changes to a public interface -> only update version and file version and leave assembly version as is

@AwMalka AwMalka requested a review from amitla February 16, 2020 07:28
@DannyVarod DannyVarod merged commit 3c8d90f into pub-comp:master May 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants