Caching
Complete Example
Runtime And Lifecycle Notes
Cache(undefined)removes the key unless negative caching is configured.Cache#setExpire(seconds)uses seconds.defineCachetyped placeholders supportstring,number, andboolean.RedisCache.loadCache()returnsread,write,remove,has, andmulti.RedisCache.removeTag(tag)removes tagged cache entries.fieldablecaches use Redis hashes and cannot combine with stale or negative cache options.Scheduler.add()supports cron strings and{ delay }.Scheduler.load()reads default exports from*.schedule.*files produced bydefineJob().scanDirectory()matches.ts,.js,.tsx,.jsx, and.mjs.scanDirectory()only parses and returns the structuredroutewhen routing consumers opt in withfileRoutes: true; that AST covers the file-relative route whileroutePathretains the configured prefix. This keeps router-native prefixes out of the portable file-name DSL and preserves non-routing loaders’ filename contracts..d.tsand source-map files do not match.parseFileRoute()accepts static,[id], and final required[...paths]segments, and rejects duplicate or object-meta dynamic names.compileFileRoute()targets eitherfind-my-wayorrou3, compiles configured native or bracket-style prefixes separately, and rejects parameter-name collisions across the complete route.
Anti-Patterns
- Returning raw values from
defineCachehandlers instead ofnew Cache(value). - Treating cache as source of truth.
- Forgetting to destroy manually created Redis or TypeORM clients.
- Scheduling jobs without idempotency when side effects can repeat.