Object cache refactor (#7558)

* fix: cache refactor

db.getObjectField no longer loads entire object
db.getObjectsFields only clones data once
more tests

* feat: add back cache to redis

db.getObjectField no longer loads entire object
This commit is contained in:
Barış Soner Uşaklı
2019-04-24 14:38:46 -04:00
committed by GitHub
parent e81a1dbb65
commit 2c98dd5f9d
5 changed files with 180 additions and 98 deletions

View File

@@ -92,6 +92,20 @@ describe('Hash methods', function () {
});
});
});
it('should work for field names with "." in them when they are cached', function (done) {
db.setObjectField('dotObject3', 'my.dot.field', 'foo2', function (err) {
assert.ifError(err);
db.getObject('dotObject3', function (err, data) {
assert.ifError(err);
db.getObjectField('dotObject3', 'my.dot.field', function (err, value) {
assert.ifError(err);
assert.equal(value, 'foo2');
done();
});
});
});
});
});
describe('getObject()', function () {
@@ -113,6 +127,15 @@ describe('Hash methods', function () {
done();
});
});
it('should return null if key is falsy', function (done) {
db.getObject(null, function (err, data) {
assert.ifError(err);
assert.equal(arguments.length, 2);
assert.equal(data, null);
done();
});
});
});
describe('getObjects()', function () {
@@ -163,6 +186,15 @@ describe('Hash methods', function () {
done();
});
});
it('should return null if key is falsy', function (done) {
db.getObjectField(null, 'test', function (err, data) {
assert.ifError(err);
assert.equal(arguments.length, 2);
assert.equal(data, null);
done();
});
});
});
describe('getObjectFields()', function () {
@@ -188,6 +220,15 @@ describe('Hash methods', function () {
done();
});
});
it('should return null if key is falsy', function (done) {
db.getObjectFields(null, ['test', 'foo'], function (err, data) {
assert.ifError(err);
assert.equal(arguments.length, 2);
assert.equal(data, null);
done();
});
});
});
describe('getObjectsFields()', function () {