code: public Long setnx(String key, Object value, int expiration) throws Exception {
          Long result = 0L;
          Jedis jedis = null;
          try {
              jedis = this.jedisPool.getResource();
              result = jedis.setnx(SafeEncoder.encode(key), serialize(value));
              jedis.expire(SafeEncoder.encode(key), expiration);
              return result;
          } catch (Exception e) {
              logger.error(e.getMessage(), e);
              this.jedisPool.returnBrokenResource(jedis);
              throw e;
          } finally {
              if (jedis != null) {
                  this.jedisPool.returnResource(jedis);
              }
          }
      }
docs: Set key to hold string value if key does not exist. In that case, it is equal to SET.
  When key already holds a value, no operation is performed. SETNX is short for "SET if N ot e X ists".
  
  @param key        Key to be operated.
  @param value      Value to be set.
  @param expiration Expiration time
  
  @return 1 if the key was set, 0 if hte key was not set.
  
  @throws Exception if execute failed.
  @see <a href="http://redis.io/commands/setnx">Redis: SETNX</a>