rename fetchTTL to ttl

This commit is contained in:
Sami Samhuri 2013-06-08 16:17:42 -07:00
parent 3fbf082cbe
commit 140e441919
3 changed files with 9 additions and 9 deletions

View file

@ -87,7 +87,7 @@ if (opt && opt[0] == '-') {
case '-t':
case '--ttl':
var name = process.argv[3];
kwikemon.fetchTTL(name, function(err, ttl) {
kwikemon.ttl(name, function(err, ttl) {
if (typeof ttl == 'number') {
console.log(ttl);
process.exit(0);

View file

@ -9,7 +9,7 @@ module.exports = {
// read
, exists: callbackOptional(exists)
, fetch: callbackOptional(fetch)
, fetchTTL: callbackOptional(fetchTTL)
, ttl: callbackOptional(ttl)
, list: list
, fetchAll: fetchAll
, count: count
@ -122,7 +122,7 @@ function fetch(name, cb) {
redis.hgetall(k(name), cb);
}
function fetchTTL(name, cb) {
function ttl(name, cb) {
redis.ttl(k(name), cb);
}

12
test.js
View file

@ -37,7 +37,7 @@ describe("kwikemon", function() {
it("should set custom ttls", function(done) {
kwikemon.set('foo', 'bar', { ttl: 1 }, function(err) {
kwikemon.fetchTTL('foo', function(err, ttl) {
kwikemon.ttl('foo', function(err, ttl) {
assert(ttl <= 1);
done();
});
@ -46,7 +46,7 @@ describe("kwikemon", function() {
it("should not expire with a ttl of zero", function(done) {
kwikemon.set('foo', 'bar', { ttl: 0 }, function(err) {
kwikemon.fetchTTL('foo', function(err, ttl) {
kwikemon.ttl('foo', function(err, ttl) {
assert(ttl == -1);
done();
});
@ -55,7 +55,7 @@ describe("kwikemon", function() {
it("should not expire when ttl is < 0", function(done) {
kwikemon.set('foo', 'bar', { ttl: -1 }, function(err) {
kwikemon.fetchTTL('foo', function(err, ttl) {
kwikemon.ttl('foo', function(err, ttl) {
assert(ttl == -1);
done();
});
@ -115,10 +115,10 @@ describe("kwikemon", function() {
});
});
describe("#fetchTTL", function() {
describe("#ttl", function() {
it("should fetch the last TTL set", function(done) {
kwikemon.set('foo', 'bar', { ttl: 300 }, function(err) {
kwikemon.fetchTTL('foo', function(err, ttl) {
kwikemon.ttl('foo', function(err, ttl) {
assert(ttl <= 300);
done();
});
@ -126,7 +126,7 @@ describe("kwikemon", function() {
});
it("should return -1 for non-existent monitors", function(done) {
kwikemon.fetchTTL('non-existent', function(err, ttl) {
kwikemon.ttl('non-existent', function(err, ttl) {
assert(ttl == -1);
done();
});