You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the above conversation, the user raised an issue with using Request.tagged and Equal.equals for requests that contain non-primitive parameters. It was observed that two requests with equal values are not considered equal according to Equal.equals if they contain non-primitive parameters. This can lead to caching not working for these types of requests.
To address this issue, there are a few best practices to consider:
Use the Data module for internal objects: By using the Data module for non-primitive parameters, you can ensure that they are compared by value rather than by reference. This can help in achieving the desired behavior for caching.
Implement custom Equals for Request objects: Another approach is to manually implement the Equals function for Request objects. This allows you to customize how the objects are compared, taking into account the specific properties that should be considered for equality.
Consider comparing specific properties: In some cases, comparing specific properties, such as an "id" field, may be sufficient for determining equality. This can be a simpler approach, especially for entities where the unique identifier is the most important factor.
Overall, the key takeaway is that when dealing with requests that have non-primitive parameters, it's important to ensure that the equality comparison is implemented correctly to enable caching and other desired behaviors.
Summary
In the above conversation, the user raised an issue with using
Request.tagged
andEqual.equals
for requests that contain non-primitive parameters. It was observed that two requests with equal values are not considered equal according toEqual.equals
if they contain non-primitive parameters. This can lead to caching not working for these types of requests.To address this issue, there are a few best practices to consider:
Use the Data module for internal objects: By using the Data module for non-primitive parameters, you can ensure that they are compared by value rather than by reference. This can help in achieving the desired behavior for caching.
Implement custom Equals for Request objects: Another approach is to manually implement the Equals function for Request objects. This allows you to customize how the objects are compared, taking into account the specific properties that should be considered for equality.
Consider comparing specific properties: In some cases, comparing specific properties, such as an "id" field, may be sufficient for determining equality. This can be a simpler approach, especially for entities where the unique identifier is the most important factor.
Overall, the key takeaway is that when dealing with requests that have non-primitive parameters, it's important to ensure that the equality comparison is implemented correctly to enable caching and other desired behaviors.
Discord thread
https://discord.com/channels/795981131316985866/1214495832246853682
The text was updated successfully, but these errors were encountered: