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

Allow a plugin to supply its own query cache implementation #12881

Merged

Conversation

martijnvg
Copy link
Member

No description provided.

bind(QueryCache.class).to(queryCacheImpl).in(Scopes.SINGLETON);
}

public void setQueryCacheClass(Class<? extends QueryCache> queryCacheClass) {
Copy link
Member

Choose a reason for hiding this comment

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

Can we do a named implementation instead? See the ExtensionPoint class that was added recently. I think these should be named (as they are now with "index" and "none") and registered, and then set with the "index.queries.cache.type" setting as the others are.

Copy link
Contributor

Choose a reason for hiding this comment

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

tricky.. if a plugin needs to wrap the cache to apply certain cache behavior regardless of the specific cache impl, named caches are not enough. I do like idea of having an extensible named cache though, so maybe we can have both? maybe introduce the notion of a cache wrapper?

Copy link
Member

Choose a reason for hiding this comment

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

The plugin can set additionalSettings that specify the cache impl it wants to force.

Copy link
Contributor

Choose a reason for hiding this comment

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

sure, but with the recent changes, it won't be able to do that if the setting already exists

Copy link
Member

Choose a reason for hiding this comment

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

It still can. The plugin just needs to enforce that the user settings cannot contain that setting (so that the additional settings are not overriden by the user settings). This can be done by throwing an exception on init.

Copy link
Contributor

Choose a reason for hiding this comment

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

that will prevent user defined cache implementation + cache wrapping. We should still enable custom query implementations while enable plugins to enforce things like making certain queries "non-cacheable"

Copy link
Member

Choose a reason for hiding this comment

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

Except the current implementation I see for these type of things does a complete override, not wrapping (and how would you wrap a class for binding? you need an instance?). If we want to allow custom filtering on top of setting a custom cache, then we should have the necessary extension points to customize or configure the cache for this behavior.

@martijnvg martijnvg force-pushed the allow_for_customable_query_cache branch from de01985 to b4526cc Compare August 16, 2015 22:04
@martijnvg
Copy link
Member Author

@uboness @rjernst I've updated the PR use ExtensionPoint to register query cache implementations.

I think the fact that a plugin can fail initialization if another query cache implementation has been configured via node/index settings than the implementation a plugin wishes to use, is sufficient for now.

@rjernst
Copy link
Member

rjernst commented Aug 16, 2015

Looks good, but can you add a test? See for example SearchModuleTests. Check a custom one can be registered and set, and that registering a duplicate name fails.

@martijnvg
Copy link
Member Author

@rjernst I've added a test.

@rjernst
Copy link
Member

rjernst commented Aug 16, 2015

LGTM, thanks!

@martijnvg martijnvg force-pushed the allow_for_customable_query_cache branch from 1be6acb to 12c40fa Compare August 17, 2015 07:55
@s1monw
Copy link
Contributor

s1monw commented Aug 17, 2015

LGTM 2

@martijnvg martijnvg removed the review label Aug 17, 2015
martijnvg added a commit that referenced this pull request Aug 17, 2015
…ache

Allow a plugin to supply its own query cache implementation
@martijnvg martijnvg merged commit e649d96 into elastic:master Aug 17, 2015
martijnvg added a commit that referenced this pull request Aug 17, 2015
…ache

Allow a plugin to supply its own query cache implementation
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.

None yet

5 participants