Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create named classes for cache objects #9

Merged
merged 3 commits into from Aug 15, 2014
Merged

Conversation

@kpdecker
Copy link
Contributor

kpdecker commented Aug 15, 2014

This makes heampdump and coredump analysis dramatically easier as cached entries will appear in the respective tools as MemoryCacheSegement and MemoryCacheEntry rather than generic objects. This allows for much simpler analysis of the memory impact of the cache as a whole.

kpdecker added 2 commits Aug 15, 2014
This makes heampdump and coredump analysis dramatically easier as cached entries will appear in the respective tools as `MemoryCacheSegement` and `MemoryCacheEntry` rather than generic objects. This allows for much simpler analysis of the memory impact of the cache as a whole.
internals.MemoryCacheSegment = function MemoryCacheSegment() {
};

internals.MemoryCacheEntry = function MemoryCacheEntry(key, value, ttl) {

This comment has been minimized.

Copy link
@geek

geek Aug 15, 2014

Member

function MemoryCacheEntry (key, value, ttl) {

internals.MemoryCacheEntry = function MemoryCacheEntry(key, value, ttl) {

// stringify() to prevent value from changing while in the cache
var stringifiedValue = JSON.stringify(value);

This comment has been minimized.

Copy link
@geek

geek Aug 15, 2014

Member

should this be wrapped in a try to catch issues with circular references?

This comment has been minimized.

Copy link
@kpdecker

kpdecker Aug 15, 2014

Author Contributor

The existing try handles that. Doing that was easier than localizing it in here as the callback flow control needs to manage the caller more than this specific function.

@@ -172,7 +181,7 @@ internals.Connection.prototype.drop = function (key, callback) {
if (segment) {
var item = segment[key.id];

if (item && item.byteSize) {

This comment has been minimized.

Copy link
@geek

geek Aug 15, 2014

Member

is this a safe change, will it ever be null?

This comment has been minimized.

Copy link
@kpdecker

kpdecker Aug 15, 2014

Author Contributor

With this change we are always setting byteSize, regardless of the setting state. This is minimal overhead and it seemed like it could be useful for debugging.

@geek geek added the enhancement label Aug 15, 2014
@geek geek added this to the 1.0.5 milestone Aug 15, 2014
@geek geek self-assigned this Aug 15, 2014
geek added a commit that referenced this pull request Aug 15, 2014
Create named classes for cache objects
@geek geek merged commit 41ca85e into hapijs:master Aug 15, 2014
1 check passed
1 check passed
continuous-integration/travis-ci The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.