mirror of
https://github.com/azures04/crafatar.git
synced 2026-03-21 23:41:18 +01:00
Date.now() is faster (and shorter) than new Date().getTime()
This commit is contained in:
parent
9e3ef8087e
commit
a22454e6e4
@ -99,7 +99,7 @@ exp.info = function(callback) {
|
|||||||
exp.update_timestamp = function(rid, userId, hash, temp, callback) {
|
exp.update_timestamp = function(rid, userId, hash, temp, callback) {
|
||||||
logging.log(rid, "cache: updating timestamp");
|
logging.log(rid, "cache: updating timestamp");
|
||||||
var sub = temp ? (config.local_cache_time - 60) : 0;
|
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
|
// store userId in lower case if not null
|
||||||
userId = userId && userId.toLowerCase();
|
userId = userId && userId.toLowerCase();
|
||||||
redis.hmset(userId, "t", time, function(err) {
|
redis.hmset(userId, "t", time, function(err) {
|
||||||
@ -114,7 +114,7 @@ exp.update_timestamp = function(rid, userId, hash, temp, callback) {
|
|||||||
// +callback+ contans error
|
// +callback+ contans error
|
||||||
exp.save_hash = function(rid, userId, skin_hash, cape_hash, callback) {
|
exp.save_hash = function(rid, userId, skin_hash, cape_hash, callback) {
|
||||||
logging.log(rid, "cache: saving skin:" + skin_hash + " cape:" + cape_hash);
|
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"
|
// store shorter null byte instead of "null"
|
||||||
skin_hash = (skin_hash === null ? "" : skin_hash);
|
skin_hash = (skin_hash === null ? "" : skin_hash);
|
||||||
cape_hash = (cape_hash === null ? "" : cape_hash);
|
cape_hash = (cape_hash === null ? "" : cape_hash);
|
||||||
|
|||||||
@ -225,7 +225,7 @@ exp.get_image_hash = function(rid, userId, type, callback) {
|
|||||||
if (err) {
|
if (err) {
|
||||||
callback(err, -1, null);
|
callback(err, -1, null);
|
||||||
} else {
|
} 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
|
// use cached image
|
||||||
logging.log(rid, "userId cached & recently updated");
|
logging.log(rid, "userId cached & recently updated");
|
||||||
callback(null, (cached_hash ? 1 : 0), cached_hash);
|
callback(null, (cached_hash ? 1 : 0), cached_hash);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user