pinia-orm icon indicating copy to clipboard operation
pinia-orm copied to clipboard

perf(pinia-orm): add caching for same `get` requests

Open CodeDredd opened this issue 3 years ago • 0 comments

🔗 Linked issue

❓ Type of change

  • [ ] 📖 Documentation (updates to the documentation or readme)
  • [ ] 🐞 Bug fix (a non-breaking change that fixes an issue)
  • [ ] 👌 Enhancement (improving an existing functionality like performance)
  • [x] ✨ New feature (a non-breaking change that adds functionality)
  • [ ] ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

📚 Description

Right now if you execute a get request (also find, etc.) then this request is always making the whol script chain which makes it pretty slow in big storages or if you execute the same get request very often.

This implements a simple caching storage like all other libaries have (vuex-orm-cache, vue-query, ....)

Get Speed test for 10k saved items and 5 same queries

get(): with cache: 371.033ms
time query 1: 370.344ms
time query 2: 0.08ms
time query 3: 0.024ms
time query 4: 0.023ms
time query 5: 0.029ms

get(): without cache: 705.5ms
time query without 1: 151.915ms
time query without 2: 140.015ms
time query without 3: 137.248ms
time query without 4: 137.401ms
time query without 5: 137.139ms

📝 Checklist

  • [ ] I have linked an issue or discussion.
  • [ ] I have updated the documentation accordingly.

CodeDredd avatar Aug 29 '22 10:08 CodeDredd