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:
parent
f045a71ebe
commit
d810416370
@ -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;
|
||||
});
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user