当前位置: 首页>>代码示例>>Java>>正文


Java Pipeline.hset方法代码示例

本文整理汇总了Java中redis.clients.jedis.Pipeline.hset方法的典型用法代码示例。如果您正苦于以下问题:Java Pipeline.hset方法的具体用法?Java Pipeline.hset怎么用?Java Pipeline.hset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在redis.clients.jedis.Pipeline的用法示例。


在下文中一共展示了Pipeline.hset方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: rename

import redis.clients.jedis.Pipeline; //导入方法依赖的package包/类
@Override
public void rename(String fileLengthKey, String fileDataKey, String oldField, String newField, List<byte[]> values, long
        fileLength) {
    long blockSize = 0;
    Jedis jedis = null;
    try {
        jedis = jedisPool.getResource();
        Pipeline pipelined = jedis.pipelined();
        //add new file length
        pipelined.hset(fileLengthKey.getBytes(), newField.getBytes(), Longs.toByteArray(fileLength));
        //add new file content
        blockSize = getBlockSize(fileLength);
        for (int i = 0; i < blockSize; i++) {
            pipelined.hset(fileDataKey.getBytes(), getBlockName(newField, i), compressFilter(values.get(i)));
        }
        values.clear();
        pipelined.sync();
    } finally {
        jedis.close();
        deleteFile(fileLengthKey, fileDataKey, oldField, blockSize);
    }
}
 
开发者ID:shijiebei2009,项目名称:RedisDirectory,代码行数:23,代码来源:JedisPoolStream.java

示例2: saveFile

import redis.clients.jedis.Pipeline; //导入方法依赖的package包/类
@Override
public void saveFile(String fileLengthKey, String fileDataKey, String fileName, List<byte[]> values, long fileLength) {
    Jedis jedis = null;
    try {
        jedis = jedisPool.getResource();
        Pipeline pipelined = jedis.pipelined();
        pipelined.hset(fileLengthKey.getBytes(), fileName.getBytes(), Longs.toByteArray(fileLength));
        Long blockSize = getBlockSize(fileLength);
        for (int i = 0; i < blockSize; i++) {
            pipelined.hset(fileDataKey.getBytes(), getBlockName(fileName, i), compressFilter(values.get(i)));
            if (i % Constants.SYNC_COUNT == 0) {
                pipelined.sync();
                pipelined = jedis.pipelined();
            }
        }
        values.clear();
        pipelined.sync();
    } finally {
        jedis.close();
    }
}
 
开发者ID:shijiebei2009,项目名称:RedisDirectory,代码行数:22,代码来源:JedisPoolStream.java

示例3: rename

import redis.clients.jedis.Pipeline; //导入方法依赖的package包/类
@Override
public void rename(String fileLengthKey, String fileDataKey, String oldField, String newField, List<byte[]> values, long
        fileLength) {
    Jedis jedis = openJedis();
    Pipeline pipelined = jedis.pipelined();
    //add new file length
    pipelined.hset(fileLengthKey.getBytes(), newField.getBytes(), Longs.toByteArray(fileLength));
    //add new file content
    Long blockSize = getBlockSize(fileLength);
    for (int i = 0; i < blockSize; i++) {
        pipelined.hset(fileDataKey.getBytes(), getBlockName(newField, i), compressFilter(values.get(i)));
    }
    pipelined.sync();
    jedis.close();
    values.clear();
    deleteFile(fileLengthKey, fileDataKey, oldField, blockSize);
}
 
开发者ID:shijiebei2009,项目名称:RedisDirectory,代码行数:18,代码来源:JedisStream.java

示例4: saveFile

import redis.clients.jedis.Pipeline; //导入方法依赖的package包/类
@Override
public void saveFile(String fileLengthKey, String fileDataKey, String fileName, List<byte[]> values, long fileLength) {
    Jedis jedis = openJedis();
    Pipeline pipelined = jedis.pipelined();
    pipelined.hset(fileLengthKey.getBytes(), fileName.getBytes(), Longs.toByteArray(fileLength));
    Long blockSize = getBlockSize(fileLength);
    for (int i = 0; i < blockSize; i++) {
        pipelined.hset(fileDataKey.getBytes(), getBlockName(fileName, i), compressFilter(values.get(i)));
        if (i % Constants.SYNC_COUNT == 0) {
            pipelined.sync();
            pipelined = jedis.pipelined();
        }
    }
    pipelined.sync();
    jedis.close();
    values.clear();
}
 
开发者ID:shijiebei2009,项目名称:RedisDirectory,代码行数:18,代码来源:JedisStream.java

示例5: doUpsertHash

import redis.clients.jedis.Pipeline; //导入方法依赖的package包/类
private void doUpsertHash(Record record, List<ErrorRecord> tempRecords, Pipeline pipeline, String key, Field value)
    throws StageException {
  if (value != null && value.getType().isOneOf(Field.Type.MAP, Field.Type.LIST_MAP)) {
    Map<String, Field> values = value.getValueAsMap();
    for (Map.Entry<String, Field> entry : values.entrySet()) {
      String fieldName = entry.getKey();
      String val = entry.getValue().getValueAsString();
      pipeline.hset(key, fieldName, val);
      tempRecords.add(new ErrorRecord(record, "Hash", key, val));
    }
  } else {
    LOG.error(Errors.REDIS_04.getMessage(), value.getType(), "value should be Map");
    errorRecordHandler.onError(
        new OnRecordErrorException(
            record,
            Errors.REDIS_04,
            value.getType(),
            "value should be Map"
        )
    );
  }
}
 
开发者ID:streamsets,项目名称:datacollector,代码行数:23,代码来源:RedisTarget.java

示例6: registerFakeSession

import redis.clients.jedis.Pipeline; //导入方法依赖的package包/类
private void registerFakeSession(int count, User user) {
	//Clean all sessions
	Jedis jedis = JedisFactory.getJedis();
	Pipeline pipeline = jedis.pipelined();
	Set<byte[]> strs = jedis.keys("*".getBytes());
	for ( byte[] key : strs ) {
		pipeline.del(key);
	}
	pipeline.sync();
	
	UserId userId = user.get_id();
	SessionKey sessionKey = SessionKey.createSessionKeyFromRandomString();
	user.setSessionKey(sessionKey);
	
	//Store it with machineid to redis
	jedis = JedisFactory.getJedis();
	pipeline = jedis.pipelined();
	for ( int i=0; i<count; i++ ) {
		pipeline.hset(sessionKey.toString(), SessionManager.H_MACHINE_KEY, "localhost:10000");
		pipeline.hset(userId.toString(), SessionManager.H_MACHINE_KEY, "localhost:10000");
		pipeline.hset(userId.toString(), SessionManager.H_SESSION_KEY, sessionKey.toString());
	}
	pipeline.sync();
}
 
开发者ID:wangqi,项目名称:gameserver,代码行数:25,代码来源:BceChatHandlerTest.java

示例7: setUp

import redis.clients.jedis.Pipeline; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    //input redis data
    //this action is not needed. just for understanding.
    JedisPool jedisPool = new JedisPool("127.0.0.1", 6379);
    Jedis jedis = jedisPool.getResource();
    Pipeline pipeline = jedis.pipelined();
    pipeline.hset(Const.REDIS_SERVICE_CAPACITY_DAILY, "300", "10000");
    pipeline.hset(Const.REDIS_SERVICE_CAPACITY_MINUTELY, "300", "2000");
    pipeline.hset(Const.REDIS_APP_RATELIMIT_DAILY, "100", "10000");
    pipeline.hset(Const.REDIS_APP_RATELIMIT_MINUTELY, "100", "1500");
    pipeline.sync();
    jedis.close();
}
 
开发者ID:longcoding,项目名称:undefined-gateway,代码行数:15,代码来源:ProxyServiceTest.java

示例8: doOrderNotSafe

import redis.clients.jedis.Pipeline; //导入方法依赖的package包/类
/**
 * 当无竞争情况时下单
 *
 * @param bracketMap bracket
 * @param jedis      redis连接
 */
public void doOrderNotSafe(Map<String, String> bracketMap, String userId, String bracketId, Jedis jedis) {
    int size = bracketMap.size();
    String sha;
    if (this.scriptSHA.get(size) == null) {
        StringBuilder updateBuilder = new StringBuilder();
        for (int i = 1; i <= size; i++) {
            updateBuilder.append(" redis.call('decrby',KEYS[").append(i).append("],ARGV[").append(i).append("])");
        }
        sha = jedis.scriptLoad(updateBuilder.substring(1));
        this.scriptSHA.put(3 + size, sha);
    } else {
        sha = this.scriptSHA.get(3 + size);
    }
    List<String> keyList = new ArrayList<>();
    List<String> paramList = new ArrayList<>();

    for (String key : bracketMap.keySet()) {
        keyList.add(Const.FOOD_STOCKS + key);
        paramList.add(bracketMap.get(key));
    }
    Pipeline pipeline = jedis.pipelined();
    pipeline.evalsha(sha, keyList, paramList);
    pipeline.hdel(Const.BRACKET_ID_BUFFER, bracketId);
    pipeline.hset(Const.ORDER_ID_BUFFER, userId, bracketId);
    pipeline.sync();
}
 
开发者ID:WhiteBlue,项目名称:eleme-hackathon,代码行数:33,代码来源:CoreService.java

示例9: updateUserSessionMap

import redis.clients.jedis.Pipeline; //导入方法依赖的package包/类
/**
	 * Update the user's session map in Redis.
	 * 
	 * @param userSessionKey
	 * @param isAI
	 * @return
	 */
	@Override
	public boolean updateUserSessionMap(SessionKey userSessionKey, 
			SessionKey roomSessionKey, boolean isAI, Pipeline pipeline) {
		pipeline.hset(userSessionKey.toString(), H_ROOM_SESSION_KEY, roomSessionKey.toString());
//		pipeline.hset(userSessionKey.toString(), H_ISAI, V_FALSE);
		return true;
	}
 
开发者ID:wangqi,项目名称:gameserver,代码行数:15,代码来源:RedisRoomManager.java

示例10: cleanUpPlayer

import redis.clients.jedis.Pipeline; //导入方法依赖的package包/类
public static void cleanUpPlayer(String player, Pipeline rsc) {
    rsc.srem("proxy:" + RedisBungee.getApi().getServerId() + ":usersOnline", player);
    rsc.hdel("player:" + player, "server", "ip", "proxy");
    long timestamp = System.currentTimeMillis();
    rsc.hset("player:" + player, "online", String.valueOf(timestamp));
    rsc.publish("redisbungee-data", RedisBungee.getGson().toJson(new DataManager.DataManagerMessage<>(
            UUID.fromString(player), DataManager.DataManagerMessage.Action.LEAVE,
            new DataManager.LogoutPayload(timestamp))));
}
 
开发者ID:minecrafter,项目名称:RedisBungee,代码行数:10,代码来源:RedisUtil.java

示例11: cacheDataRaw

import redis.clients.jedis.Pipeline; //导入方法依赖的package包/类
private void cacheDataRaw(Pipeline pipeline, KeyType key, ValueType data) {
    try {
        // Transform typed key -> redis key (field in redis hash), and encode data -> string
        pipeline.hset(cacheKey, keyTypeToRedisKey.apply(key), valueTypeSerializationHelper.encode(data));
        // Encode typed key -> string to remove from missing set.
        pipeline.srem(cacheMissingKey(), keyTypeSerializationHelper.encode(key));
    } catch(Exception jpe) {
        Throwables.propagate(jpe);
    }
}
 
开发者ID:lithiumtech,项目名称:rdbi,代码行数:11,代码来源:RedisHashCache.java

示例12: hashSet

import redis.clients.jedis.Pipeline; //导入方法依赖的package包/类
private void hashSet(Jedis jedis, String cacheKey, String hfield, CacheWrapper<Object> result) throws Exception {
    byte[] key=KEY_SERIALIZER.serialize(cacheKey);
    byte[] field=KEY_SERIALIZER.serialize(hfield);
    byte[] val=serializer.serialize(result);
    int hExpire;
    if(hashExpire < 0) {
        hExpire=result.getExpire();
    } else {
        hExpire=hashExpire;
    }
    if(hExpire == 0) {
        jedis.hset(key, field, val);
    } else if(hExpire > 0) {
        if(hashExpireByScript) {
            String redisInstance = jedis.getClient().getHost()+":"+jedis.getClient().getPort();
            byte[] sha=HASH_SET_SCRIPT_SHA.get(redisInstance);
            if(null == sha) {
                sha=jedis.scriptLoad(hashSetScript);
                HASH_SET_SCRIPT_SHA.put(redisInstance, sha);
            }
            List<byte[]> keys=new ArrayList<byte[]>();
            keys.add(key);
            keys.add(field);

            List<byte[]> args=new ArrayList<byte[]>();
            args.add(val);
            args.add(KEY_SERIALIZER.serialize(String.valueOf(hExpire)));
            try {
                jedis.evalsha(sha, keys, args);
            } catch(Exception ex) {
                logger.error(ex.getMessage(), ex);
                try {
                    sha=jedis.scriptLoad(hashSetScript);
                    HASH_SET_SCRIPT_SHA.put(redisInstance, sha);
                    jedis.evalsha(sha, keys, args);
                } catch(Exception ex1) {
                    logger.error(ex1.getMessage(), ex1);
                }
            }
        } else {
            Pipeline p=jedis.pipelined();
            p.hset(key, field, val);
            p.expire(key, hExpire);
            p.sync();
        }
    }
}
 
开发者ID:qiujiayu,项目名称:AutoLoadCache,代码行数:48,代码来源:ShardedJedisCacheManager.java

示例13: Battle

import redis.clients.jedis.Pipeline; //导入方法依赖的package包/类
/**
 * Create a new instance of Battle object.
 * @param battleRoom
 */
public Battle(BattleRoom battleRoom, String gameServerId) {
	this.battleRoom = battleRoom;
	this.gameServerId = gameServerId;
	
	Room roomLeft = battleRoom.getRoomLeft();
	Room roomRight = battleRoom.getRoomRight();
	roomType = roomLeft.getRoomType();
			
	List<UserInfo> users1 = roomLeft.getUserInfoList();
	this.userLeftList = makeUserList(users1, roomLeft.getRoomSessionKey(), 
			roomLeft.getCurrentUserCount(), BattleCamp.LEFT.id(), roomLeft.getRoomType());
	
	List<UserInfo> users2 = roomRight.getUserInfoList();
	this.userRightList = makeUserList(users2, roomRight.getRoomSessionKey(), 
			roomRight.getCurrentUserCount(), BattleCamp.RIGHT.id(), roomRight.getRoomType());
	
	this.battleUserNumber = this.userLeftList.size() + this.userRightList.size();
	
	//Choose the mapId
	this.battleMap = chooseBattleMap(roomLeft.getMapId(), roomRight.getMapId());
	
	//Save to Redis
	String gameServerValue = null;
	if ( this.gameServerId != null ) {
		gameServerValue = this.gameServerId;
	} else {
		gameServerValue = Constant.EMPTY;
	}
	Pipeline pipeline = JedisFactory.getJedis().pipelined();
	Collection<BattleUser> battleUsers = battleUserMap.values();
	for (Iterator iter = battleUsers.iterator(); iter.hasNext();) {
		BattleUser battleUser = (BattleUser) iter.next();
		pipeline.hset(battleUser.getUserSessionKey().toString(), BATTLE_SERVER_KEY, gameServerValue);
		pipeline.hset(battleUser.getUserSessionKey().toString(), BATTLE_SESSION_KEY, 
				this.battleRoom.getSessionKey().toString());
	}
	pipeline.sync();

	//Setup relationship here
	if ( this.battleRoom.getRoomRight().getRoomType() != RoomType.PVE_ROOM ) {
		setupRelation();
	}
	
	/**
	 * Store the battle room type.
	 */
	battleRoomType = this.battleRoom.getRoomLeft().getRoomType();
}
 
开发者ID:wangqi,项目名称:gameserver,代码行数:53,代码来源:Battle.java

示例14: createPlayer

import redis.clients.jedis.Pipeline; //导入方法依赖的package包/类
protected static void createPlayer(ProxiedPlayer player, Pipeline pipeline, boolean fireEvent) {
    createPlayer(player.getPendingConnection(), pipeline, fireEvent);
    if (player.getServer() != null)
        pipeline.hset("player:" + player.getUniqueId().toString(), "server", player.getServer().getInfo().getName());
}
 
开发者ID:minecrafter,项目名称:RedisBungee,代码行数:6,代码来源:RedisUtil.java


注:本文中的redis.clients.jedis.Pipeline.hset方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。