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


Java Jedis.pipelined方法代码示例

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


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

示例1: rename

import redis.clients.jedis.Jedis; //导入方法依赖的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: deleteFile

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
/**
 * Use transactions to delete index file
 *
 * @param fileLengthKey
 * @param fileDataKey
 * @param field
 * @param blockSize
 */
@Override
public void deleteFile(String fileLengthKey, String fileDataKey, String field, long blockSize) {
    Jedis jedis = null;
    try {
        jedis = jedisPool.getResource();
        Pipeline pipelined = jedis.pipelined();
        //delete file length
        pipelined.hdel(fileLengthKey.getBytes(), field.getBytes());
        //delete file content
        for (int i = 0; i < blockSize; i++) {
            byte[] blockName = getBlockName(field, i);
            pipelined.hdel(fileDataKey.getBytes(), blockName);
        }
        pipelined.sync();
    } finally {
        jedis.close();
    }
}
 
开发者ID:shijiebei2009,项目名称:RedisDirectory,代码行数:27,代码来源:JedisPoolStream.java

示例3: saveFile

import redis.clients.jedis.Jedis; //导入方法依赖的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

示例4: rename

import redis.clients.jedis.Jedis; //导入方法依赖的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

示例5: saveFile

import redis.clients.jedis.Jedis; //导入方法依赖的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

示例6: main

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
public static void main(String[] args) throws UnknownHostException, IOException {
  Jedis jedis = new Jedis(hnp.getHost(), hnp.getPort());
  jedis.connect();
  jedis.auth("foobared");
  jedis.flushAll();

  long begin = Calendar.getInstance().getTimeInMillis();

  Pipeline p = jedis.pipelined();
  for (int n = 0; n <= TOTAL_OPERATIONS; n++) {
    String key = "foo" + n;
    p.set(key, "bar" + n);
    p.get(key);
  }
  p.sync();

  long elapsed = Calendar.getInstance().getTimeInMillis() - begin;

  jedis.disconnect();

  System.out.println(((1000 * 2 * TOTAL_OPERATIONS) / elapsed) + " ops");
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:23,代码来源:PipelinedGetSetBenchmark.java

示例7: loadFileOnce

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public List<byte[]> loadFileOnce(String fileDataKey, String fileName, long blockSize) {
    Jedis jedis = jedisPool.getResource();
    Pipeline pipelined = jedis.pipelined();
    List<byte[]> res = new ArrayList<>();
    List<Response<byte[]>> temps = new ArrayList<>();
    int temp = 0;
    while (temp < blockSize) {
        Response<byte[]> data = pipelined.hget(fileDataKey.getBytes(), getBlockName(fileName, temp));
        temps.add(data);
        if (temp % Constants.SYNC_COUNT == 0) {
            pipelined.sync();
            res.addAll(temps.stream().map(response -> uncompressFilter(response.get())).collect(Collectors.toList()));
            pipelined = jedis.pipelined();
            temps.clear();
        }
        temp++;
    }
    try {
        pipelined.sync();
    } catch (JedisConnectionException e) {
        log.error("pipelined = {}, blockSize = {}!", pipelined.toString(), blockSize);
        log.error("", e);
    } finally {
        jedis.close();
    }
    res.addAll(temps.stream().map(response -> uncompressFilter(response.get())).collect(Collectors.toList()));
    temps.clear();
    return res;
}
 
开发者ID:shijiebei2009,项目名称:RedisDirectory,代码行数:31,代码来源:JedisPoolStream.java

示例8: deleteFile

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public void deleteFile(String fileLengthKey, String fileDataKey, String field, long blockSize) {
    Jedis jedis = openJedis();
    Pipeline pipelined = jedis.pipelined();
    //delete file length
    pipelined.hdel(fileLengthKey.getBytes(), field.getBytes());
    //delete file content
    for (int i = 0; i < blockSize; i++) {
        byte[] blockName = getBlockName(field, i);
        pipelined.hdel(fileDataKey.getBytes(), blockName);
    }
    pipelined.sync();
    jedis.close();
}
 
开发者ID:shijiebei2009,项目名称:RedisDirectory,代码行数:15,代码来源:JedisStream.java

示例9: loadFileOnce

import redis.clients.jedis.Jedis; //导入方法依赖的package包/类
@Override
public List<byte[]> loadFileOnce(String fileDataKey, String fileName, long blockSize) {
    Jedis jedis = openJedis();
    Pipeline pipelined = jedis.pipelined();
    List<byte[]> res = new ArrayList<>();
    List<Response<byte[]>> temps = new ArrayList<>();
    int temp = 0;
    while (temp < blockSize) {
        Response<byte[]> data = pipelined.hget(fileDataKey.getBytes(), getBlockName(fileName, temp));
        temps.add(data);
        if (temp % Constants.SYNC_COUNT == 0) {
            pipelined.sync();
            res.addAll(temps.stream().map(response -> uncompressFilter(response.get())).collect(Collectors.toList()));
            temps.clear();
            pipelined = jedis.pipelined();
        }
        temp++;
    }
    try {
        pipelined.sync();
    } catch (JedisConnectionException e) {
        log.error("pipelined = {}, blockSize = {}!", pipelined.toString(), blockSize);
        log.error("", e);
    } finally {
        jedis.close();
    }
    res.addAll(temps.stream().map(response -> uncompressFilter(response.get())).collect(Collectors.toList()));
    temps.clear();
    return res;
}
 
开发者ID:shijiebei2009,项目名称:RedisDirectory,代码行数:31,代码来源:JedisStream.java


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