Skip to content

Add implicit query caching support #339

@DarkDust

Description

@DarkDust

Sparked by #337, the idea is to implement caching of parsed queries so that repeated calls to something like node.select(someQueryString) are only parsed once.

This task is meant to discuss how we want to do that. Main issue is that the caching must be limited: if a user builds dynamic queries which are not reused, a naive boundless cache would be similar to a memory leak.

Current options:

  • NSCache
    • As far as I can tell, it should be available on Linux as well.
    • Automatically responds to memory pressure on Apple platforms. Not sure about Linux.
    • Major downside: it's not sendable.
  • LRUCache
    • Automatically responds to memory pressure on iOS, but not yet on macOS?
    • Sendable.
    • Downside: it's an external dependency. Currently aligns with our deployment targets so should be fine.

LRUCache looks like a good fit.

Some way of configuring the cache would be nice, but in a way that's implementation agnostic so we can switch to a different cache implementation if needed/wanted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions