zenstackhq / zenstack

Fullstack TypeScript toolkit that enhances Prisma ORM with flexible Authorization layer for RBAC/ABAC/PBAC/ReBAC, offering auto-generated type-safe APIs and frontend hooks.
https://zenstack.dev
MIT License
2.07k stars 89 forks source link

[Feature Request] Caching Mechanism for `zenstack generate` Command #1550

Open tmax22 opened 3 months ago

tmax22 commented 3 months ago

Hello Zenstack Team,

I'm writing to request a caching mechanism for the zenstack generate command. Currently, when dealing with large schemas containing many tables, the generation process becomes time-consuming.

  1. Caching: Implement a caching system that stores results from previous runs and reuses them if the schema hasn’t changed.
    • each plugin should decide for himself if it is safe to skip.
    • if plugin has not skipped, internal skips within each plugin can take place. for example, save cache for generated hooks/zod schemas per each table. if table wasn't change can take values from cache.
  2. Cache Invalidation: Provide a --no-cache or --force flag to manually invalidate the cache and regenerate everything from scratch.

currently generation for us takes few minutes and keeps going up. implementing such caching mechanism can easily speed up generation process from 10 minutes to few seconds.

and once again, thank for the amazing zenstack framework.

ymc9 commented 3 months ago

Hi @tmax22 , yes, I can understand it gets painful when the schema gets more and more complex. We'll think about this and also the overall generation performance. Thanks for the continuous support!

baenio commented 1 week ago

Great suggestion! 🎉

I completely agree - as the schema grows, the generation time increases significantly, which can be quite a bottleneck. Implementing a caching mechanism would be a game-changer for anyone working with large and complex schemas. It would drastically improve productivity by cutting down the generation time from minutes to seconds. A --no-cache or --force flag is also a brilliant addition, giving users full control over when to refresh the cache.

Looking forward to any updates on this – it would be amazing to know if there’s any progress on implementing this feature! 🚀