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: caching the opensea response causing the TypeError when deserializing #661

Merged
merged 2 commits into from
Feb 9, 2024

Conversation

crnkovic
Copy link
Contributor

@crnkovic crnkovic commented Feb 8, 2024

Summary

https://app.clickup.com/t/86drgahvk

The problem is that we used to cache the entire OpenSea response, which is serialized and put into Redis, then deserialized. It can't properly be deserialized, and thus failed. We can cache the JSON response, though. That can be serialized with no issues.

As a bonus, I inlined the OpenSea API URL and the version as there is no more v1.

What we did:

Cache::remember('key', $ttl, fn () => Http::get('/some-endpoint'));

What we need to do:

Cache::remember('key', $ttl, fn () => Http::get('/some-endpoint')->json());

When testing and after deployment, please clear cache: php artisan cache:clear

To test, set cache driver to redis, open tinker, and run the following code twice Opensea::getCollectionFloorPrice('proof-moonbirds').

> Opensea::getCollectionFloorPrice('test')
[!] Aliasing 'Opensea' to 'App\Support\Facades\Opensea' for this Tinker session.
= App\Data\Web3\Web3CollectionFloorPrice {#8824
    +price: "0",
    +currency: "eth",
    +retrievedAt: Carbon\Carbon @1707404494 {#8869
      date: 2024-02-08 15:01:34.394680 UTC (+00:00),
    },
  }

> Opensea::getCollectionFloorPrice('test')

   TypeError  fseek(): Argument #1 ($stream) must be of type resource, int given.

Clear cache and try again after this PR.

Checklist

  • I checked my UI changes against the design and there are no notable differences
  • I checked my UI changes for any responsiveness issues
  • I checked my (code) changes for obvious issues, debug statements and commented code
  • I opened a corresponding card on Clickup for any remaining TODOs in my code
  • I added a short description on how to test this PR (if necessary)
  • I added a storybook entry for the component that was added (if necessary)
  • Documentation (if necessary)
  • Tests (if necessary)
  • Ready to be merged

@ItsANameToo ItsANameToo changed the title fix: caching the opensea response object causes the TypeError when deserializing fix: caching the opensea response causing the TypeError when deserializing Feb 9, 2024
@ItsANameToo ItsANameToo merged commit a5f68d9 into develop Feb 9, 2024
12 checks passed
@ItsANameToo ItsANameToo deleted the fix/opensea branch February 9, 2024 08:51
@ItsANameToo ItsANameToo modified the milestones: 0.14.0, 0.13.1 Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants