GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Redis supports cluster configuration by wanglinlin8 · Pull Request #463 · uavorg/uavstack

Redis supports cluster configuration #463

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.

Sign up for GitHub

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

Merged
zengli00 merged 2 commits into uavorg:master from wanglinlin8:master
Dec 21, 2018

Uh oh!

There was an error while loading. Please reload this page.

Merged

Redis supports cluster configuration #463

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit Hold shift + click to select a range
7668026
Merge pull request #6 from uavorg/master
wanglinlin8 Dec 18, 2018
48ec4e8
https://github.com/uavorg/uavstack/issues/462
Dec 18, 2018
File filter
Filter by extension


Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view
Prev Previous commit
https://github.com/uavorg/uavstack/issues/462
Redis supports cluster configuration
  • Loading branch information

Uh oh!

There was an error while loading. Please reload this page.

linlinwang3
linlinwang3 committed Dec 18, 2018
commit 48ec4e835bef37a8d714df0ce79f39c7cdc06b6f

There are no files selected for viewing

38 changes: 37 additions & 1 deletion 38 com.creditease.uav.cache.redis/pom.xml
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,42 @@
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
</dependency>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.1.11.Final</version>
</dependency>
<dependency>
<groupId>io.lettuce</groupId>
<artifactId>lettuce-core</artifactId>
<version>5.0.5.RELEASE</version>
<exclusions>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-common</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-transport</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-resolver</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
</exclusion>
<exclusion>
<groupId>io.netty</groupId>
<artifactId>netty-codec</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
60 changes: 47 additions & 13 deletions 60 com.creditease.uav.cache.redis/src/main/java/com/creditease/uav/cache/api/CacheManager.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,20 @@ public static void build(String cacheServerAddress, int minConcurrent, int maxCo
private CacheService service;

private L1Cache l1cache;


private static CacheClientMode clientMode;

protected CacheManager(String cacheServerAddress, int minConcurrent, int maxConcurrent, int queueSize,
String password) {
service = CacheFactory.instance().createCacheService(CacheClientMode.AREDIS, cacheServerAddress, minConcurrent,

if (cacheServerAddress.contains(",")) {
clientMode = CacheClientMode.LETTUCE;
}
else {
clientMode = CacheClientMode.AREDIS;
}

service = CacheFactory.instance().createCacheService(clientMode, cacheServerAddress, minConcurrent,
maxConcurrent, queueSize, password);
l1cache = new L1Cache();
}
Expand Down Expand Up @@ -1239,7 +1249,8 @@ public void putHash(String region, String key, Map<String, String> fieldValues,
* @param fieldNames
* @return
*/
public Map<String, String> getHash(String region, String key, String... fieldNames) {
@SuppressWarnings("unchecked")
public Map<String, String> getHash(String region, String key, String... fieldNames) {

if (null == fieldNames) {
Collections.emptyMap();
Expand All @@ -1253,8 +1264,13 @@ public Map<String, String> getHash(String region, String key, String... fieldNam

if (null != results && results.length > 0) {

Map<String, String> value = genHMGetResults(fieldNames, results);

Map<String, String> value = new HashMap<String, String>();
if (clientMode.equals(CacheClientMode.LETTUCE) && results[0] instanceof Map) {
value = (Map<String, String>) results[0];
}
else {
value = genHMGetResults(fieldNames, results);
}
return value;
}

Expand Down Expand Up @@ -1321,8 +1337,13 @@ public Map<String, String> getHashAll(String region, String key) {

if (null != results && results.length > 0) {

Map<String, String> value = genHMGetResults(null, results);

Map<String, String> value = new HashMap<String, String>();
if (clientMode.equals(CacheClientMode.LETTUCE) && results[0] instanceof Map) {
value = (Map<String, String>) results[0];
}
else {
value = genHMGetResults(null, results);
}
this.l1cache.put(rkey, value);

return value;
Expand Down Expand Up @@ -1362,7 +1383,14 @@ public void getHashAll(String region, String key, AsyncCacheCallback<Map<String,
public void process(CommandInfo[] command, Object[] result, Throwable throwable) {

if (fcallback != null && null != result && result.length > 0) {
Map<String, String> mresult = genHMGetResults(null, result);
Map<String, String> mresult = new HashMap<String, String>();

if (clientMode.equals(CacheClientMode.LETTUCE) && result[0] instanceof Map) {
mresult = (Map<String, String>) result[0];
}
else {
mresult = genHMGetResults(null, result);
}

/**
* get hash all是可以放L1Cache
Expand Down Expand Up @@ -1403,12 +1431,18 @@ public void getHash(String region, String key, AsyncCacheCallback<Map<String, St

doCacheCommand(ci, new AbstractAsyncHandler<CommandInfo>() {

@Override
@SuppressWarnings("unchecked")
@Override
public void process(CommandInfo[] command, Object[] result, Throwable throwable) {

if (fcallback != null && null != result && result.length > 0) {
Map<String, String> mresult = genHMGetResults(ffieldname, result);

if (fcallback != null && null != result && result.length > 0) {
Map<String, String> mresult = new HashMap<String, String>();
if (clientMode.equals(CacheClientMode.LETTUCE) && result[0] instanceof Map) {
mresult = (Map<String, String>) result[0];
}
else {
mresult = genHMGetResults(ffieldname, result);
}
fcallback.onResult(mresult);
}
}
Expand Down Expand Up @@ -1795,7 +1829,7 @@ public List lrange(String region, String key, int start, int end) {
Object[] results = service.submitCommands(
new CommandInfo(CommandInfo.RedisCommand.LRANGE, rkey, String.valueOf(start), String.valueOf(end)));

if (null != results && results.length > 0) {
if (null != results && results.length > 0 && results[0] != null) {

Object[] objs = (Object[]) results[0];

Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.