ttl
获取单行数据的TTL时间。TTL表示Time To Live,表示该数据还能存活多久。如果超过存活时间,数据就读不到了。
- /**
- * Get ttl time.
- * @param tableName TableHandler name
- * @param hashKey used to decide which partition to put this k-v,
- * if null or length == 0, means hash key is "".
- * @param sortKey all the k-v under hashKey will be sorted by sortKey,
- * if null or length == 0, means sort key is "".
- * @return ttl time in seconds; -1 if no ttl set; -2 if not exist.
- * @throws PException
- */
- public int ttl(String tableName, byte[] hashKey, byte[] sortKey) throws PException;
注:
- 参数:需传入TableName、HashKey、SortKey。
- 返回值:TTL时间,单位为秒。如果该数据没有设置TTL,返回-1;如果该数据不存在,返回-2。
- 异常:如果出现异常,譬如网络错误、超时错误、服务端错误等,会抛出 PException。