注意: (1) executePipelined()的callback参数,实现execute() 方法只能返回null,否则会报错。 报错: InvalidDataAccessApiUsageException: Callback cannot return a non-null value as it gets overwritten by the pipeline 源码如下:
Object result = executeSession(session);
if (result != null) {
throw new InvalidDataAccessApiUsageException(
"Callback cannot return a non-null value as it gets overwritten by the pipeline");
}
/**
* Get the value of {@code key}.
*
* @param key must not be {@literal null}.
* 在管道(pipeline)中使用 get()方法 得到的value会是null
* @return {@literal null} when used in pipeline / transaction.
*/
@Nullable
V get(Object key);
redisTemplate获取管道返回值:
List list = stringRedisTemplate.executePipelined(new SessionCallback() {
@Override
public String execute(@NonNull RedisOperations operations) throws DataAccessException {
//idList是多个id的集合
for (String id : idList) {
//key由前缀加唯一id组成
String key = KEY_PREFIX + id;
//在管道中使用 get()方法 得到的value会是null。value通过executePipelined()的返回值List获取。
operations.opsForHash().get(key, field);
}
//Callback只能返回null, 否则报错:
// InvalidDataAccessApiUsageException: Callback cannot return a non-null value as it gets overwritten by the pipeline
return null;
}
});
list.forEach(System.out::println);
Create the Google Play Account
Having a Google account, pay 25$, then you get your google developer account.
References:
http://developer.android.com/distribute/googleplay/start.html
https://p