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

Add support for bounded Redisson map cache (max size configuration). #985

Merged
merged 3 commits into from
Sep 4, 2017

Conversation

johnou
Copy link
Contributor

@johnou johnou commented Jul 24, 2017

Currently RedissonMapCache creates an unbounded set in Redis which may cause problems in certain cache implementations.

Thanks for the heavy lifting @zuanoc !

@johnou johnou changed the title Add support max size configuration for RedissonMapCache. Add support bounded Redisson map cache (max size configuration). Jul 24, 2017
@johnou johnou changed the title Add support bounded Redisson map cache (max size configuration). Add support for bounded Redisson map cache (max size configuration). Jul 24, 2017
final int maxSize = 2;
Map<String, String> store = new LinkedHashMap<String, String>() {
@Override
protected boolean removeEldestEntry(Entry<String, String> eldest) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

required as store represents an onheap cache, not the cache in redis.

Copy link
Member

@mrniko mrniko left a comment

Choose a reason for hiding this comment

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

@johnou Great contribution. Please consider my comments, before I merge

" end;" +
" end;" +
"end;" +
"return map;",
Arrays.<Object>asList(getName(), getTimeoutSetName(), getIdleSetName()), args.toArray());
Copy link
Member

Choose a reason for hiding this comment

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

@johnou getLastAccessTimeSetName() is missed

+ "return 0; "
+ "end",
Arrays.<Object>asList(getName(key), getTimeoutSetNameByKey(key), getIdleSetNameByKey(key), getRemovedChannelNameByKey(key),
getLastAccessTimeSetName()),
Copy link
Member

Choose a reason for hiding this comment

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

@johnou getLastAccessTimeSetNameByKey should be used instead

+ "return val;"
+ "end; ",
Arrays.<Object>asList(getName(key), getTimeoutSetNameByKey(key), getIdleSetNameByKey(key), getCreatedChannelNameByKey(key),
getLastAccessTimeSetName(), getRemovedChannelName()),
Copy link
Member

Choose a reason for hiding this comment

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

@johnou getLastAccessTimeSetNameByKey, getRemovedChannelNameByKey should be used instead

+ "end; ",
Arrays.<Object>asList(getName(key), getTimeoutSetNameByKey(key), getIdleSetNameByKey(key), getCreatedChannelNameByKey(key)),
System.currentTimeMillis(), ttlTimeout, maxIdleTimeout, maxIdleDelta, encodeMapKey(key), encodeMapValue(value));
"local insertable = false; "
Copy link
Member

Choose a reason for hiding this comment

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

@johnou please format this lua-script properly

+ "if t ~= 0 then "
+ "local expireIdle = redis.call('zscore', KEYS[3], ARGV[2]); "
+ "if expireIdle ~= false then "
"local v = redis.call('hget', KEYS[1], ARGV[2]); "
Copy link
Member

Choose a reason for hiding this comment

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

@johnou please format this lua-script properly


+ "return val; ",
Arrays.<Object>asList(getName(key), getTimeoutSetNameByKey(key), getIdleSetNameByKey(key), getUpdatedChannelNameByKey(key)),
"local value = redis.call('hget', KEYS[1], ARGV[2]); "
Copy link
Member

Choose a reason for hiding this comment

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

@johnou please format this lua-script properly

@zuanoc zuanoc force-pushed the feature/map_cache_max_size branch 2 times, most recently from edb4e9b to 8e906ba Compare August 29, 2017 12:12
@zuanoc
Copy link

zuanoc commented Aug 29, 2017

@mrniko PTAL

@mrniko mrniko added this to the 2.10.2 milestone Aug 31, 2017
@mrniko mrniko added the feature label Aug 31, 2017
@mrniko mrniko merged commit a38bbe7 into redisson:3.0.0 Sep 4, 2017
@mrniko
Copy link
Member

mrniko commented Sep 4, 2017

@zuanoc @johnou please merge it with "master" branch

@johnou
Copy link
Contributor Author

johnou commented Sep 4, 2017

@mrniko #1027

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

Successfully merging this pull request may close these issues.

None yet

3 participants