Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolves #1507 introduce an in-memory cache (Node.js) #1523

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

ggrossetie
Copy link
Member

resolves #1507

@ggrossetie ggrossetie force-pushed the issue-1507-content-uri-cache branch 2 times, most recently from ea1863b to a59b15d Compare December 31, 2021 19:18
@ggrossetie
Copy link
Member Author

This pull request provides a custom implement of open-uri/cached.
The implement is heavily inspired by: https://github.com/isaacs/node-lru-cache but does not rely on it (mostly to avoid additional dependencies).

This pull requests also introduces an API to interact with the cache:

Asciidoctor.Cache.enable()
Asciidoctor.Cache.disable()
Asciidoctor.Cache.setMax(500)
Asciidoctor.Cache.reset()

@ggrossetie ggrossetie marked this pull request as ready for review January 4, 2022 13:02
Comment on lines +28 to +33
def require_library name, gem_name = true, on_failure = :abort
if name == 'open-uri/cached'
`return Opal.Asciidoctor.Cache.enable()`
end
original_require_library name, gem_name, on_failure
end
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mojavelinux I'm a bit concerned about this hack, could we find a better "hook" in Asciidoctor core?

@ggrossetie
Copy link
Member Author

Waiting for a change in Asciidoctor core to properly hook the in-memory cache.

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

Successfully merging this pull request may close these issues.

Implement the content URI caching feature in a Node environment
1 participant