ikyriak / IdempotentAPI

A .NET library that handles the HTTP write operations (POST and PATCH) that can affect only once for the given request data and idempotency-key by using an ASP.NET Core attribute (filter).
MIT License
253 stars 38 forks source link

IdempotentAPI with dotnet 6 and FusionCache not sending back cached data #33

Closed MohamadTahir closed 2 years ago

MohamadTahir commented 2 years ago

Hello, so I am using IdempotentAPI with .net 6 and FusionCache with Redis, I went through your documentation and the fusionCache documentation I got everything up and running.

I can see that the has access and is storing my data on my Redis database, I set up Redis-commander and I can clearly see the data in Redis.

when I call my endpoint I get back data new data every time altho I am providing it with the same IdempotencyKey

info: IdempotentAPI.Core.Idempotency[0] IdempotencyFilterAttribute [Before Controller execution]: Request for POST: [/v1/roles/test]() received (50 bytes) IdempotentAPI.Core.Idempotency: Information: IdempotencyFilterAttribute [Before Controller execution]: Request for POST: [/v1/roles/test]() received (50 bytes) info: IdempotentAPI.Core.Idempotency[0] IdempotencyFilterAttribute [Before Controller]: Return result from idempotency cache (of type Microsoft.AspNetCore.Mvc.ObjectResult) IdempotentAPI.Core.Idempotency: Information: IdempotencyFilterAttribute [Before Controller]: Return result from idempotency cache (of type Microsoft.AspNetCore.Mvc.ObjectResult) info: IdempotentAPI.Core.Idempotency[0] IdempotencyFilterAttribute [Before Controller]: End IdempotentAPI.Core.Idempotency: Information: IdempotencyFilterAttribute [Before Controller]: End info: IdempotentAPI.Core.Idempotency[0] IdempotencyFilterAttribute [Before Controller execution]: Request for POST: [/v1/roles/test]() received (50 bytes) IdempotentAPI.Core.Idempotency: Information: IdempotencyFilterAttribute [Before Controller execution]: Request for POST: [/v1/roles/test]() received (50 bytes) info: IdempotentAPI.Core.Idempotency[0] IdempotencyFilterAttribute [Before Controller]: Return result from idempotency cache (of type Microsoft.AspNetCore.Mvc.ObjectResult) IdempotentAPI.Core.Idempotency: Information: IdempotencyFilterAttribute [Before Controller]: Return result from idempotency cache (of type Microsoft.AspNetCore.Mvc.ObjectResult) info: IdempotentAPI.Core.Idempotency[0] IdempotencyFilterAttribute [Before Controller]: End

let me know if I'm doing anything wrong, or if you require more logs/information.

MohamadTahir commented 2 years ago

So after more digging up and testing, it turns out that you actually need to return an "ActionResult" of your object not return the object directly.

The documentation does not mention that it is required to return an ActionResult of the object. I am not sure if this is an intended thing or it is just a result of the rest of my configurations. @RichardGreen-IS2 @ikyriak can you please confirm?

ikyriak commented 2 years ago

Hello @MohamadTahir,

Thanks for taking the time to report and investigate this issue!

This was a bug, and now it is fixed šŸ˜„. Can you please try the latest version (v1.0.1) of the IdempotentAPI NuGet package to confirm that everything is working for you?

MohamadTahir commented 2 years ago

Hey @ikyriak I am very sorry for the late reply.

give me a day or two to test the new version and I will get back to you :) thank you.

ikyriak commented 2 years ago

I am closing this issue based on the committed fix. However, feel free to reopen if the problem still exists.

Thank you šŸ˜„