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

added pluggable key creation strategy: support for compound keys and prefix #7

Closed
wants to merge 3 commits into from

Conversation

sv3ndk
Copy link

@sv3ndk sv3ndk commented Oct 15, 2013

Hi,

The current version of the MemcachedState does not support compound keys. Also, if several parts of the topology save distinct states to memcached, the current implementation could lead to key overlap and thus destruction of state information. For example, a count grouping/saving by word running simultaneously to a count grouping/saving by first letter of the word could both yield key overlap for one-letter words like "a" in English or "y" in French.

I added a mechanism that delegates to a IStateSingleKeyBuilder to make the creation of memcached key more flexible. I also added a default ConcatKeyBuilder implementation of IStateSingleKeyBuilder, which just concatenates the toString() of the compound key to solve issue 1 and allows a optional prefix to be configured to solve issue 2.

The new usage is backward compatible with the old syntax. I illustrate the new features in the updated example in Test.java.

Unfortunately, I had to de-activate usage of CachedMap to have this working: data with compound keys put in the CachedMap by the example topology are never retrieved. I failed to understand why and failed to reproduce a bug with junit in CachedMap with compound keys. Simply commenting out CachedMap from MemcachedState solved the issue.

@sv3ndk sv3ndk closed this Apr 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant