{"action":"created","issue":{"url":"https://api.github.com/repos/tcs-de/nodecache/issues/36","labels_url":"https://api.github.com/repos/tcs-de/nodecache/issues/36/labels{/name}","comments_url":"https://api.github.com/repos/tcs-de/nodecache/issues/36/comments","events_url":"https://api.github.com/repos/tcs-de/nodecache/issues/36/events","html_url":"https://github.com/tcs-de/nodecache/issues/36","id":102524563,"number":36,"title":"get exact vsize","user":{"login":"neophob","id":837347,"avatar_url":"https://avatars.githubusercontent.com/u/837347?v=3","gravatar_id":"","url":"https://api.github.com/users/neophob","html_url":"https://github.com/neophob","followers_url":"https://api.github.com/users/neophob/followers","following_url":"https://api.github.com/users/neophob/following{/other_user}","gists_url":"https://api.github.com/users/neophob/gists{/gist_id}","starred_url":"https://api.github.com/users/neophob/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neophob/subscriptions","organizations_url":"https://api.github.com/users/neophob/orgs","repos_url":"https://api.github.com/users/neophob/repos","events_url":"https://api.github.com/users/neophob/events{/privacy}","received_events_url":"https://api.github.com/users/neophob/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-22T10:46:56Z","updated_at":"2015-08-26T06:06:07Z","closed_at":null,"body":"Hi thanks for your lib, very usefull. however there is a small issue, I put elements in my cache that look like this:\r\n\r\n```\r\nvar element = { buffer: aNodeBufferObject, contentType : 'image/png' };\r\n```\r\nthe vsize for this type does not match, as it just don't know the type. maybe it would make sense to add an optional key into the element that specify the exact size? another idea would be to define a function that returns the exact size of an element.\r\n\r\nwhat do you think?\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/tcs-de/nodecache/issues/comments/134847811","html_url":"https://github.com/tcs-de/nodecache/issues/36#issuecomment-134847811","issue_url":"https://api.github.com/repos/tcs-de/nodecache/issues/36","id":134847811,"user":{"login":"mpneuried","id":300631,"avatar_url":"https://avatars.githubusercontent.com/u/300631?v=3","gravatar_id":"","url":"https://api.github.com/users/mpneuried","html_url":"https://github.com/mpneuried","followers_url":"https://api.github.com/users/mpneuried/followers","following_url":"https://api.github.com/users/mpneuried/following{/other_user}","gists_url":"https://api.github.com/users/mpneuried/gists{/gist_id}","starred_url":"https://api.github.com/users/mpneuried/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mpneuried/subscriptions","organizations_url":"https://api.github.com/users/mpneuried/orgs","repos_url":"https://api.github.com/users/mpneuried/repos","events_url":"https://api.github.com/users/mpneuried/events{/privacy}","received_events_url":"https://api.github.com/users/mpneuried/received_events","type":"User","site_admin":false},"created_at":"2015-08-26T06:06:07Z","updated_at":"2015-08-26T06:06:07Z","body":"Hi, within JS it's not simple to get the real memory size of a variable.\r\nSo nodecache tries to calc the size as simple as possibele.\r\nSee: https://github.com/tcs-de/nodecache/blob/master/_src/lib/node_cache.coffee#L437\r\n\r\nIn your case you are putting an object, witch leads to the code:\r\n```js\r\nthis.options.objectValueSize * _.size( value ) // Values: 80 * 2 -> 160\r\n```\r\n\r\nI don't want to add code or another module for a better size calculation, because this will decrease the performance for every user, just to have better stats.\r\nI hope you will agree with this.\r\n\r\nBut i could add an option where you can define a function to calculate the size your own or pass it to a module like [sizeof](https://www.npmjs.com/package/sizeof).\r\n\r\nExample:\r\n```js\r\nvar sizeof = require( \"sizeof\" )\r\nvar myCache = new NodeCache({\r\n  fnVSize: sizeof.sizeof\r\n});\r\n```"}}