Incrementing the Value of an Item in the Cache

Problem

You want to increment a value in the cache.

Solution

Use Cache::increment()

$value = Cache::increment('key');

The first time this is called $value will be 1, the next call it will return 2, and so forth.

You can also pass a value to increment.

$value = Cache::increment('key', 50);

Discussion

Doesn't work with File or Database caches.

comments powered by Disqus