Date.now() is faster (and shorter) than new Date().getTime()

This commit is contained in:
jomo 2015-03-30 23:56:44 +02:00
parent 9e3ef8087e
commit a22454e6e4
2 changed files with 3 additions and 3 deletions

View File

@ -99,7 +99,7 @@ exp.info = function(callback) {
exp.update_timestamp = function(rid, userId, hash, temp, callback) {
logging.log(rid, "cache: updating timestamp");
var sub = temp ? (config.local_cache_time - 60) : 0;
var time = new Date().getTime() - sub;
var time = Date.now() - sub;
// store userId in lower case if not null
userId = userId && userId.toLowerCase();
redis.hmset(userId, "t", time, function(err) {
@ -114,7 +114,7 @@ exp.update_timestamp = function(rid, userId, hash, temp, callback) {
// +callback+ contans error
exp.save_hash = function(rid, userId, skin_hash, cape_hash, callback) {
logging.log(rid, "cache: saving skin:" + skin_hash + " cape:" + cape_hash);
var time = new Date().getTime();
var time = Date.now();
// store shorter null byte instead of "null"
skin_hash = (skin_hash === null ? "" : skin_hash);
cape_hash = (cape_hash === null ? "" : cape_hash);

View File

@ -225,7 +225,7 @@ exp.get_image_hash = function(rid, userId, type, callback) {
if (err) {
callback(err, -1, null);
} else {
if (cache_details && cache_details[type] !== undefined && cache_details.time + config.local_cache_time * 1000 >= new Date().getTime()) {
if (cache_details && cache_details[type] !== undefined && cache_details.time + config.local_cache_time * 1000 >= Date.now()) {
// use cached image
logging.log(rid, "userId cached & recently updated");
callback(null, (cached_hash ? 1 : 0), cached_hash);