lib/encoding.js
function encoding(rtype, value, conf) {
  var enc;

  //console.dir('rtype: ' + rtype);
  //console.dir(value);

  switch(rtype) {
    case RTYPE.STRING:
      enc = ENCODING.RAW;
      // integer encoding
      if(typeof value === 'number'
        && parseInt(value) === value
        || (typeof value === 'string'
          && /^-?\d+$/.test(value))
        || (value instanceof Buffer) && isIntegerBuffer(value)) {
        enc = ENCODING.INT;
      }
      break;
    case RTYPE.LIST:
      // no ziplist support yet
      enc = ENCODING.LINKEDLIST;
      break;
    case RTYPE.SET:
      // no intset support yet
      enc = ENCODING.HASHTABLE;
      break;
    case RTYPE.HASH:
      // no zipmap support yet
      enc = ENCODING.HASHTABLE;
      break;
    case RTYPE.ZSET:
      // no ziplist support yet
      enc = ENCODING.SKIPLIST;
      break;
  }

  return enc;
}
function encoding(rtype, value, conf) {
  var enc;

  //console.dir('rtype: ' + rtype);
  //console.dir(value);

  switch(rtype) {
    case RTYPE.STRING:
      enc = ENCODING.RAW;
      // integer encoding
      if(typeof value === 'number'
        && parseInt(value) === value
        || (typeof value === 'string'
          && /^-?\d+$/.test(value))
        || (value instanceof Buffer) && isIntegerBuffer(value)) {
        enc = ENCODING.INT;
      }
      break;
    case RTYPE.LIST:
      // no ziplist support yet
      enc = ENCODING.LINKEDLIST;
      break;
    case RTYPE.SET:
      // no intset support yet
      enc = ENCODING.HASHTABLE;
      break;
    case RTYPE.HASH:
      // no zipmap support yet
      enc = ENCODING.HASHTABLE;
      break;
    case RTYPE.ZSET:
      // no ziplist support yet
      enc = ENCODING.SKIPLIST;
      break;
  }

  return enc;
}
function encoding ( rtype , value , conf ) { var enc ; //console.dir('rtype: ' + rtype); //console.dir(value); switch ( rtype ) { case RTYPE . STRING : enc = ENCODING . RAW ; // integer encoding if ( typeof value === 'number' && parseInt ( value ) === value || ( typeof value === 'string' && / ^-?\d+$ / . test ( value ) ) || ( value instanceof Buffer ) && isIntegerBuffer ( value ) ) { enc = ENCODING . INT ; } break ; case RTYPE . LIST : // no ziplist support yet enc = ENCODING . LINKEDLIST ; break ; case RTYPE . SET : // no intset support yet enc = ENCODING . HASHTABLE ; break ; case RTYPE . HASH : // no zipmap support yet enc = ENCODING . HASHTABLE ; break ; case RTYPE . ZSET : // no ziplist support yet enc = ENCODING . SKIPLIST ; break ; } return enc ; }
Determine the encoding of an object.

@param rtype The redis type string.
@param value The value of the object.
@param conf Reference to the configuration.
Determine the encoding of an object .