1
0
mirror of https://github.com/moparisthebest/mail synced 2024-11-26 02:42:17 -05:00

remove in memory caching from email dao

This commit is contained in:
Tankred Hase 2013-10-04 16:25:02 +02:00
parent f045a71ebe
commit d810416370
2 changed files with 0 additions and 80 deletions

View File

@ -564,42 +564,5 @@ define(function(require) {
}, messageReady);
};
/**
* Checks if an item is already cached and if not, cache it.
*/
EmailDAO.prototype.cacheItem = function(folderName, item) {
var self = this;
// check if account has a folders attribute
if (!self._account.folders) {
self._account.folders = {};
}
// create folder if not existant
if (!self._account.folders[folderName]) {
self._account.folders[folderName] = {};
}
// cache item
self._account.folders[folderName][item.uid] = item;
};
/**
* Fetch an item from the cache with the following id
*/
EmailDAO.prototype.readCache = function(folderName, itemId) {
var self = this;
// check if account has a folders attribute
if (!self._account.folders) {
return;
}
// check folder
if (!self._account.folders[folderName]) {
return;
}
return self._account.folders[folderName][itemId];
};
return EmailDAO;
});

View File

@ -217,49 +217,6 @@ define(function(require) {
});
});
describe('IMAP Caching', function() {
describe('write cache', function() {
it('should work if cache is empty', function() {
expect(emailDao._account.folders).to.not.exist;
emailDao.cacheItem('INBOX', {
uid: 42
});
expect(emailDao._account.folders.INBOX[42]).to.exist;
});
it('should work if cache is not empty', function() {
expect(emailDao._account.folders).to.not.exist;
emailDao.cacheItem('INBOX', {
uid: 42
});
emailDao.cacheItem('INBOX', {
uid: 43
});
expect(emailDao._account.folders.INBOX[42]).to.exist;
expect(emailDao._account.folders.INBOX[43]).to.exist;
});
});
describe('read cache', function() {
it('should work if cache is empty', function() {
expect(emailDao._account.folders).to.not.exist;
var item = emailDao.readCache('INBOX', 42);
expect(item).to.not.exist;
});
it('should work if cache is not empty', function() {
expect(emailDao._account.folders).to.not.exist;
emailDao.cacheItem('INBOX', {
uid: 42
});
expect(emailDao._account.folders.INBOX[42]).to.exist;
var item = emailDao.readCache('INBOX', 42);
expect(item.uid).to.equal(42);
});
});
});
describe('IMAP: list folders', function() {
it('should work', function(done) {
imapClientStub.listAllFolders.yields();