Skip to content
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

Fix deserialization issue in FusionCache #387

Closed
wants to merge 2 commits into from

Conversation

gmij
Copy link

@gmij gmij commented Feb 10, 2025

Related to #386

Fix deserialization issue when retrieving data from L2 Cache after an app restart.

  • FusionCacheMemoryEntry.cs

    • Update GetValue<TValue1> method to handle deserialization correctly for JsonElement and JToken.
    • Add checks to determine if the value is of type JsonElement or JToken.
    • Use the appropriate deserializer to convert JsonElement or JToken to TValue1.
  • FusionCacheNewtonsoftJsonSerializer.cs

    • Update Deserialize<T> method to handle conversion correctly for JToken.
    • Add a check to determine if the data is of type JToken.
    • Use the appropriate deserializer to convert JToken to T.
  • FusionCacheSystemTextJsonSerializer.cs

    • Update Deserialize<T> method to handle conversion correctly for JsonElement.
    • Add a check to determine if the data is of type JsonElement.
    • Use the appropriate deserializer to convert JsonElement to T.
  • SerializationTests.cs

    • Add tests to ensure deserialization works correctly after an app restart.
    • Create a test case for FusionCacheNewtonsoftJsonSerializer.
    • Create a test case for FusionCacheSystemTextJsonSerializer.

For more details, open the Copilot Workspace session.

gmij added 2 commits February 10, 2025 14:32
Related to ZiggyCreatures#386

Fix deserialization issue when retrieving data from L2 Cache after an app restart.

* **FusionCacheMemoryEntry.cs**
  - Update `GetValue<TValue1>` method to handle deserialization correctly for `JsonElement` and `JToken`.
  - Add checks to determine if the value is of type `JsonElement` or `JToken`.
  - Use the appropriate deserializer to convert `JsonElement` or `JToken` to `TValue1`.

* **FusionCacheNewtonsoftJsonSerializer.cs**
  - Update `Deserialize<T>` method to handle conversion correctly for `JToken`.
  - Add a check to determine if the data is of type `JToken`.
  - Use the appropriate deserializer to convert `JToken` to `T`.

* **FusionCacheSystemTextJsonSerializer.cs**
  - Update `Deserialize<T>` method to handle conversion correctly for `JsonElement`.
  - Add a check to determine if the data is of type `JsonElement`.
  - Use the appropriate deserializer to convert `JsonElement` to `T`.

* **SerializationTests.cs**
  - Add tests to ensure deserialization works correctly after an app restart.
  - Create a test case for `FusionCacheNewtonsoftJsonSerializer`.
  - Create a test case for `FusionCacheSystemTextJsonSerializer`.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/ZiggyCreatures/FusionCache/issues/386?shareId=XXXX-XXXX-XXXX-XXXX).
@jodydonetti
Copy link
Collaborator

Hi @gmij , was this related to #386 ?
If so, can I close this?

Thanks!

@gmij
Copy link
Author

gmij commented Feb 12, 2025

Ok。。Close.

@gmij gmij closed this Feb 12, 2025
@gmij gmij deleted the fix-deserialization branch February 12, 2025 01:23
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.

2 participants