Skip to content

Commit

Permalink
We shouldn't be doing this.
Browse files Browse the repository at this point in the history
The LRU will sever ties to the shifted object, it's up to the rest of the app to release it.

Revert "Destroying objects that get shifted out of the LRU."

This reverts commit ab5bbea.
  • Loading branch information
shajith committed Mar 29, 2012
1 parent 62aa0be commit 53ac95f
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 44 deletions.
7 changes: 2 additions & 5 deletions dist/ember-resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,6 @@ if (typeof this === 'object') this.LRUCache = LRUCache;
}());(function() {
Ember.Resource.IdentityMap = function(limit) {
this.cache = new LRUCache(limit || Ember.Resource.IdentityMap.DEFAULT_IDENTITY_MAP_LIMIT);
this.cache.shift = function() {
var obj = LRUCache.prototype.shift.call(this);
obj && obj.value && Em.Object.prototype.destroy.call(obj.value);
return obj;
};
};

Ember.Resource.IdentityMap.prototype = {
Expand Down Expand Up @@ -926,6 +921,8 @@ if (typeof this === 'object') this.LRUCache = LRUCache;
var self = this;

var updateExpiry = function() {
if(Ember.get(self, 'expireIn') === null) { return; }

var expireAt = new Date();
expireAt.setSeconds(expireAt.getSeconds() + Ember.get(self, 'expireIn'));
Ember.set(self, 'expireAt', expireAt);
Expand Down
34 changes: 0 additions & 34 deletions spec/javascripts/identityMapSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,6 @@ describe('identity map', function() {
expect(Address.identityMap.size()).toBe(10);
});

it('should call destroy on objects flushed from the identity map', function() {
var address, address1;

address1 = Address.create({id: 1});

for(var i=2; i<=10; i++) {
address = Address.create({id: i});
}

expect(address1.get('isDestroyed')).toBeFalsy();

Address.create({id: 11});

expect(address1.get('isDestroyed')).toBeTruthy();

});

describe("for resource collections", function() {
var Addresses = Em.ResourceCollection.extend();

Expand Down Expand Up @@ -70,23 +53,6 @@ describe('identity map', function() {
expect(Address.identityMap.size()).toBe(10);
});

it('should call destroy on objects flushed from the identity map', function() {
var address, address1;

address1 = Addresses.create({type: Address, url: '/address/1'});

for(var i=2; i<=10; i++) {
address = Addresses.create({type: Address, url: '/address/' + i});
}

expect(address1.get('isDestroyed')).toBeFalsy();

Addresses.create({type: Address, url: '/address/11'});

expect(address1.get('isDestroyed')).toBeTruthy();

});


});
});
5 changes: 0 additions & 5 deletions src/identity_map.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
(function() {
Ember.Resource.IdentityMap = function(limit) {
this.cache = new LRUCache(limit || Ember.Resource.IdentityMap.DEFAULT_IDENTITY_MAP_LIMIT);
this.cache.shift = function() {
var obj = LRUCache.prototype.shift.call(this);
obj && obj.value && Em.Object.prototype.destroy.call(obj.value);
return obj;
};
};

Ember.Resource.IdentityMap.prototype = {
Expand Down

0 comments on commit 53ac95f

Please sign in to comment.