Skip to content

CodisClient 二进制存储支持 #11

@EricLiutyy

Description

@EricLiutyy

1) 添加 二进制 存储支持
2)日志异常处理
3)连接泄露 、连接问题等
建议如下:

 /**
     * Eric Added
     *
     * @param key
     * @param value
     * @return
     */
 public String setObject(final String key, final Object value) {
        Jedis jediscon = null;
        try {
            jediscon = jedisPool.getResource();
            return jediscon.set(AddBid(key).getBytes(), TObjectUtils.serialize(value));
        } catch (Exception e) {
            logger.error("[BfdJodis] Set Object error...", e);
        } finally {
            if (null != jediscon) {
                jediscon.close();
            }
        }
        return "FAIL";
    }

/**
     * Added by Eric
     * <p>
     * LPush Object list
     *
     * @param key
     * @param objects
     * @return
     */
    public void lpushObject(final String key, final List objects) {
        Jedis jediscon = null;
        try {
            jediscon = jedisPool.getResource();
            for (Object o : objects) {
                try {
                    Long ret = jediscon.lpush(AddBid(key).getBytes(), TObjectUtils.serialize(o));
                    logger.info("[BfdJodis] lpush, key : {}, value: {}, ret: {}", AddBid(key).getBytes(),
                            TObjectUtils.serialize(o), ret);
                } catch (Exception e) {
                    logger.error("[BfdJodis] Error adding object to queue. o = {}", o);
                }
            }
        } catch (Exception e) {
            logger.error("[BfdJodis] Failed to lpush object list to codis...", e);
        } finally {
            if (null != jediscon) {
                jediscon.close();
            }
        }
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions