Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    Deepak Sharma
    Hi can someone explain to me that the difference between checkPeriod and ttl is? What is a cache element mentioned in the docs on stdTTL? Is it the NodeCache object or a specific key?
    M. Peter

    With stdTTL you can set the default ttl of a key, if it's not set during .set().

    ttldefines the time to live/expiring for the key you are saving to the cache.

    checkPeriod is a internal interval time to do a check of every key if it expired. It's just used to remove unused keys. The check will also performed on a key get

    Pieter Colpaert
    Quick question: would this repo work with browserify as a browser caching system?
    M. Peter
    I Never testet it with browserify. But it's not using any special module or special server features. So I guess it should work well with browserify
    Pieter Colpaert
    OK! Thanks!
    Hey guys, was wondering if we can easily add/delete objects using this module?
    I was using memcache, but their API is a PITA for deleting and managing objects/arrays :(
    (in nodejs ofc) :P
    Wyatt Johnson

    Not sure if this is a node 5.1.1 issue..

    bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },

    TypeError: Cannot read property 'apply' of undefined
    at <>/node_modules/node-cache/lib/node_cache.js:3:58
    at NodeCache (<>/node_modules/node-cache/lib/node_cache.js:48:12)

    why is gets undefined on page refresh
    Nejc Vukovic
    I have a question: how could I check for the cached object on every request? I accessibg my node route externaly with an ajax request and I woukd like to create a new cache object if the user is accessing the first time or moving forward if the object already exists. Any ideas?
    Nejc Vukovic
    Found the solution for the question before.
    Another question though: Is there a way to add new data to a cache object key?
    M. Peter
    @nVVEBd you can just overwrite the key with .set()
    Nejc Vukovic
    @mpneuried thanks for the answer but overwritting the key isn’t such a good idea. Because I want to add additional data to the key not just rewrite it. Solved that also. Just appended the data to the existing key to v:
    Ahmad El-Melegy
    Any help please ?
    Shops.all (err, shops)->
        for shop in shops
          toCache = {}
          toCache['name'] = shop['name']
          toCache['image'] = shop['image']
          toCache['translated_name'] = shop['translated_name']
          toCache['ships_to'] = shop['ships_to']
          toCache['shop_type'] = shop['shop_type']
          toCache['call_to_action'] = shop['call_to_action']
          Cache.set "shop-info-#{shop['name']}", toCache
          console.log Cache.get 'shop-info-a' // WORKS
    console.log Cache.get 'shop-info-a' // undefined
    Shops.all: (cb) ->
    M. Peter
    @AhmadMelegy Your result // undefined is correct, because your date is not loaded at this time. Your Cache.set is done after the Cache.get.
    Here's a more detailed working example in Tonic
    Robert Mennell
    Okay I'm having a problem with my cache... the .on('delete') or expired events aren't firing. Anyone else experiencing this?
    Robert Mennell
    figured it out. My check time was 600 times longer than my testing TTL
    can someone help me im getting this error
    TypeError: Method _external called on incompatible receiver #<SecureContext>
    at Function.getOwnPropertyDescriptor (<anonymous>)
    This message was deleted
    Alex Budin
    Joshua Gwosdz
    Muhand Jumah
    If I try to set a key which was set previously, would it replace or make duplicate?
    Joshua Gwosdz
    The key will be overwritten with the new value
    Joshua Gwosdz
    Deepak Mohan
    Hi All, I am new to node and please forgive me if I am asking a trivial question here... Is there a recommended limit on cache size? I have an RHEL 7 virtual machine with 4GB RAM, 2 tables I want to cache with around 10,000 rows each (and 50 and 10 columns respectively). When I export the data onto a csv, the 2 csv files are 10MB and 1MB each.
    Móricz Gergő
    hey, is this cache queued?
    hi guys. does nodecache persist?
    Móricz Gergő
    it does not. @hareendras
    Oday Nasser
    is anyone here?
    anyone knows what the cache replacement strategy used in node-cache?? So if say we reach limit (say limit 1m objects) then what happens? Does it use LRU policy??
    is there any api node-cache provided to check cache hold particular key present in cache or not?
    return like true or false?
    is this myCache.ttl(key, 100, function (err, changed) {} - working for me to check?
    Gustavo Delgado
    Hey guys, I didn't saw in the docs what storage uses the tool.
    Is just in-memory storage?
    Or can I use redis/memcache/etc ?