fix data-cache invalidation
fix data-cache invalidation

This fixes and issue with adding data to the data-cache. The previous
implementation used 'set' instead of 'add'. As discussed in
https://docs.djangoproject.com/en/dev/topics/cache/ 'set' will add the value
again, even if it exists already. This has the side-effect of also updating the
cache expiry time.

This means, that when you use 'set' on values that have been retrieved from the
cache, you keep bumping the cache expiry time and thereby extending the
life-time of the data in the cache.

This behaviour can lead to problems if you select a time in the future as your
value for the 'until' parameter in your query and then keep sending that query
at intervals smaller than the DEFAULT_CACHE_DURATION. The result is that you
will, until you cease requesting at that interval, receive the same values,
even if new values have become available in the meantime.

To reproduce select an existing metric and fix the 'from' and 'until' times to
fixed values selecting the 'until' time to be in the future:

current time is 12:0520131106:

curl "http://grphite/render/?target=METRIC&format=json&from=12:0020131106&until=12:2020131106&local=0"

Then execute the above curl statement in a while loop for about 15 minutes.
Observe how the same set of values is returned over the course of these 15
minutes.  Then, wait one minute (or whatever you set DEFAULT_CACHE_DURATION to)
and execute the curl query once again. Observe how several additional values
have appeared.

The fix is to use 'add' instead of 'set'. 'add' will only add new values if
they do not exist already.

If you apply this patch and try the same while loop again, observe how any new
values are fetched correctly one minute after they actually become available
from carbon.

Of course this depends on how often the metric is written to carbon. In my
example above my metric was written every 5 minutes.

nkhuyu/graphite-web,brutasse/graphite-web,redice/graphite-web,lfckop/graphite-web,synedge/graphite-web,section-io/graphite-web,dbn/graphite-web,atnak/graphite-web,redice/graphite-web,dhtech/graphite-web,deniszh/graphite-web,cybem/graphite-web-iow,synedge/graphite-web,obfuscurity/graphite-web,mcoolive/graphite-web,goir/graphite-web,edwardmlyte/graphite-web,g76r/graphite-web,drax68/graphite-web,AICIDNN/graphite-web,disqus/graphite-web,esnet/graphite-web,brutasse/graphite-web,cosm0s/graphite-web,drax68/graphite-web,axibase/graphite-web,piotr1212/graphite-web,krux/graphite-web,redice/graphite-web,Skyscanner/graphite-web,bbc/graphite-web,axibase/graphite-web,synedge/graphite-web,Squarespace/graphite-web,redice/graphite-web,criteo-forks/graphite-web,graphite-server/graphite-web,EinsamHauer/graphite-web-iow,Invoca/graphite-web,dbn/graphite-web,atnak/graphite-web,phreakocious/graphite-web,lfckop/graphite-web,esnet/graphite-web,lyft/graphite-web,section-io/graphite-web,cybem/graphite-web-iow,cbowman0/graphite-web,markolson/graphite-web,mcoolive/graphite-web,nkhuyu/graphite-web,blacked/graphite-web,Aloomaio/graphite-web,disqus/graphite-web,Skyscanner/graphite-web,cybem/graphite-web-iow,bbc/graphite-web,bpaquet/graphite-web,g76r/graphite-web,bmhatfield/graphite-web,bpaquet/graphite-web,gwaldo/graphite-web,cbowman0/graphite-web,penpen/graphite-web,cybem/graphite-web-iow,ZelunZhang/graphite-web,Aloomaio/graphite-web,esnet/graphite-web,goir/graphite-web,cosm0s/graphite-web,bruce-lyft/graphite-web,JeanFred/graphite-web,bruce-lyft/graphite-web,redice/graphite-web,blacked/graphite-web,goir/graphite-web,cgvarela/graphite-web,Aloomaio/graphite-web,Squarespace/graphite-web,Invoca/graphite-web,g76r/graphite-web,jssjr/graphite-web,criteo-forks/graphite-web,jssjr/graphite-web,deniszh/graphite-web,obfuscurity/graphite-web,atnak/graphite-web,zBMNForks/graphite-web,edwardmlyte/graphite-web,mcoolive/graphite-web,blacked/graphite-web,gwaldo/graphite-web,atnak/graphite-web,markolson/graphite-web,JeanFred/graphite-web,synedge/graphite-web,phreakocious/graphite-web,dbn/graphite-web,Invoca/graphite-web,esnet/graphite-web,brutasse/graphite-web,penpen/graphite-web,graphite-server/graphite-web,obfuscurity/graphite-web,Aloomaio/graphite-web,graphite-project/graphite-web,nkhuyu/graphite-web,krux/graphite-web,bmhatfield/graphite-web,atnak/graphite-web,johnseekins/graphite-web,bpaquet/graphite-web,lyft/graphite-web,blacked/graphite-web,SEJeff/graphite-web,obfuscurity/graphite-web,bbc/graphite-web,johnseekins/graphite-web,cgvarela/graphite-web,atnak/graphite-web,bmhatfield/graphite-web,bmhatfield/graphite-web,axibase/graphite-web,dhtech/graphite-web,bpaquet/graphite-web,graphite-project/graphite-web,lfckop/graphite-web,cgvarela/graphite-web,phreakocious/graphite-web,EinsamHauer/graphite-web-iow,synedge/graphite-web,cgvarela/graphite-web,g76r/graphite-web,krux/graphite-web,pu239ppy/graphite-web,drax68/graphite-web,graphite-project/graphite-web,lfckop/graphite-web,graphite-server/graphite-web,graphite-server/graphite-web,Invoca/graphite-web,lyft/graphite-web,JeanFred/graphite-web,kkdk5535/graphite-web,graphite-server/graphite-web,synedge/graphite-web,krux/graphite-web,Skyscanner/graphite-web,Squarespace/graphite-web,dhtech/graphite-web,cybem/graphite-web-iow,piotr1212/graphite-web,zBMNForks/graphite-web,redice/graphite-web,penpen/graphite-web,Aloomaio/graphite-web,EinsamHauer/graphite-web-iow,JeanFred/graphite-web,jssjr/graphite-web,ZelunZhang/graphite-web,nkhuyu/graphite-web,section-io/graphite-web,phreakocious/graphite-web,ZelunZhang/graphite-web,bbc/graphite-web,EinsamHauer/graphite-web-iow,johnseekins/graphite-web,ZelunZhang/graphite-web,DanCech/graphite-web,criteo-forks/graphite-web,esnet/graphite-web,kkdk5535/graphite-web,goir/graphite-web,krux/graphite-web,dbn/graphite-web,Invoca/graphite-web,drax68/graphite-web,JeanFred/graphite-web,dhtech/graphite-web,bruce-lyft/graphite-web,cbowman0/graphite-web,zBMNForks/graphite-web,cosm0s/graphite-web,edwardmlyte/graphite-web,SEJeff/graphite-web,mcoolive/graphite-web,gwaldo/graphite-web,graphite-project/graphite-web,blacked/graphite-web,ZelunZhang/graphite-web,deniszh/graphite-web,markolson/graphite-web,disqus/graphite-web,bpaquet/graphite-web,zBMNForks/graphite-web,zBMNForks/graphite-web,brutasse/graphite-web,JeanFred/graphite-web,krux/graphite-web,jssjr/graphite-web,disqus/graphite-web,pu239ppy/graphite-web,brutasse/graphite-web,goir/graphite-web,nkhuyu/graphite-web,Squarespace/graphite-web,EinsamHauer/graphite-web-iow,piotr1212/graphite-web,dhtech/graphite-web,lfckop/graphite-web,AICIDNN/graphite-web,kkdk5535/graphite-web,zBMNForks/graphite-web,penpen/graphite-web,piotr1212/graphite-web,deniszh/graphite-web,penpen/graphite-web,criteo-forks/graphite-web,axibase/graphite-web,markolson/graphite-web,deniszh/graphite-web,cgvarela/graphite-web,section-io/graphite-web,DanCech/graphite-web,obfuscurity/graphite-web,piotr1212/graphite-web,cbowman0/graphite-web,gwaldo/graphite-web,AICIDNN/graphite-web,AICIDNN/graphite-web,ZelunZhang/graphite-web,g76r/graphite-web,criteo-forks/graphite-web,Squarespace/graphite-web,AICIDNN/graphite-web,penpen/graphite-web,AICIDNN/graphite-web,dbn/graphite-web,drax68/graphite-web,gwaldo/graphite-web,graphite-server/graphite-web,graphite-project/graphite-web,bruce-lyft/graphite-web,cbowman0/graphite-web,pu239ppy/graphite-web,deniszh/graphite-web,pu239ppy/graphite-web,obfuscurity/graphite-web,lyft/graphite-web,DanCech/graphite-web,graphite-project/graphite-web,pu239ppy/graphite-web,g76r/graphite-web,lyft/graphite-web,cosm0s/graphite-web,SEJeff/graphite-web,gwaldo/graphite-web,edwardmlyte/graphite-web,lyft/graphite-web,bruce-lyft/graphite-web,kkdk5535/graphite-web,mcoolive/graphite-web,phreakocious/graphite-web,kkdk5535/graphite-web,bbc/graphite-web,piotr1212/graphite-web,johnseekins/graphite-web,Aloomaio/graphite-web,EinsamHauer/graphite-web-iow,lfckop/graphite-web,disqus/graphite-web,criteo-forks/graphite-web,johnseekins/graphite-web,jssjr/graphite-web,blacked/graphite-web,drax68/graphite-web,mcoolive/graphite-web,bmhatfield/graphite-web,edwardmlyte/graphite-web,section-io/graphite-web,cosm0s/graphite-web,bmhatfield/graphite-web,DanCech/graphite-web,axibase/graphite-web,jssjr/graphite-web,DanCech/graphite-web,Invoca/graphite-web,Squarespace/graphite-web,cbowman0/graphite-web,pu239ppy/graphite-web,SEJeff/graphite-web,bruce-lyft/graphite-web,nkhuyu/graphite-web,cybem/graphite-web-iow,markolson/graphite-web,Skyscanner/graphite-web,kkdk5535/graphite-web,bpaquet/graphite-web,phreakocious/graphite-web,section-io/graphite-web,johnseekins/graphite-web,dbn/graphite-web,brutasse/graphite-web,edwardmlyte/graphite-web,Skyscanner/graphite-web,disqus/graphite-web,SEJeff/graphite-web,DanCech/graphite-web,goir/graphite-web,cosm0s/graphite-web,Skyscanner/graphite-web,axibase/graphite-web,cgvarela/graphite-web