AspNetCore.CacheOutput icon indicating copy to clipboard operation
AspNetCore.CacheOutput copied to clipboard

Provide ability to add CacheOutputUntil

Open hflexgrig opened this issue 5 years ago • 6 comments

In my current project there's need to add specific times per day, when 3th party resources getting updated and we need to invalidate cache. e.g.

[CacheOutputUntil(ServerTime = "00:00:00 , 08:00:00, 15:35 , 22:00")]

I started work on it, will make pull request soon. But this is work in process, need few days to test everything and tuneup.

hflexgrig avatar Sep 06 '21 17:09 hflexgrig

@Iamcerba What you think about this functionality? would you like I contribute it here or I should continue it on my forked repo? Because in our project we need this functionality! And also I'll try to complete it on weekends.

hflexgrig avatar Sep 08 '21 16:09 hflexgrig

Have you tried https://github.com/Iamcerba/AspNetCore.CacheOutput/blob/master/AspNetCore.CacheOutput/TimeAttributes/CacheOutputUntilCacheAttribute.cs ?

Iamcerba avatar Sep 08 '21 17:09 Iamcerba

Yeah I saw it before, it uses one time per day, but in our project external source updates twice a day, so having multiple times with integers not really useful, thats why I've used comma separated string.

hflexgrig avatar Sep 08 '21 17:09 hflexgrig

It is better to implement in your fork because as for me it looks not really useful for most of people currently. I don't have enough time to unit test even existing code (

Iamcerba avatar Sep 08 '21 17:09 Iamcerba

For your case, it might be useful to invalidate cache manually from another controller via a direct call to https://github.com/Iamcerba/AspNetCore.CacheOutput/blob/master/AspNetCore.CacheOutput/IApiCacheOutput.cs#L8

Or if invalidation logic is not in the API you may also create a background worker that invalidates cache based on schedule, like Hangfire for example.

Iamcerba avatar Sep 08 '21 17:09 Iamcerba

Yeah, I was thinking about hangfire..

hflexgrig avatar Sep 08 '21 18:09 hflexgrig