Skip to content

Conversation

0bex0
Copy link

@0bex0 0bex0 commented May 22, 2025

What issue does this pull request resolve?

#2554 (comment)

What changes did you make?

Implemented noCache instance option, allowing users to avoid using internal cache to minimise unnecessary memory usage in applications with lots of large schemas.

The addSchema function allows users to cache schemas under a user-defined key or the schemaId value. However, if users choose to use this more efficient key system, the whole schema is still entered into the internal _cache, meaning:

  • SchemaEnv object is stored twice, in Ajv.schemas and in Ajv._cache
  • The schema object is stored as Ajv._cache key

For large schemas this is less memory efficient than using compile alone. By adding the noCache option, this allows users to re-use validation functions through addSchema and getSchema without having to store entire schemas in Ajv._cache keys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant