Question: How to store the temporary data in Apache storm?

In storm topology, bolt needs to access the previously processed data.

```
Eg: if the bolt processes varaiable1 with result as 20 at 10:00 AM.

```

and again `varaiable1` is received as `50` at `10:15 AM` then the result should be `30 (50-20)` 

later if varaiable1 receives `70` then the result should be `20 (70-50)` at `10:30`.

How to achieve this functionality.

Answer: 
I'm afraid there is no such built-in functionality as of today.
But you can use any kind of distributed cache, like memcached or Redis. Those caching solutions are really easy to use.
Uou can use CacheBuilder to remember your data within your extended BaseRichBolt (put this in the prepare method):

```
// init your cache.
this.cache = CacheBuilder.newBuilder()
                         .maximumSize(maximumCacheSize)
                         .expireAfterWrite(expireAfterWrite, TimeUnit.SECONDS)
                         .build();

```

Then in execute, you can use the cache to see if you have already seen that key entry or not. from there you can add your business logic:

```
// if we haven't seen it before, we can emit it.
if(this.cache.getIfPresent(key) == null) {
    cache.put(key, nearlyEmptyList);
    this.collector.emit(input, input.getValues());
}

this.collector.ack(input);

```