Refactoring increment and decrement in local cache

The increment and decrement commands are exactly same, so their logic is being refactored. I created a new method ``increment_or_decrement`` which carries out the logic of an increment or decrement.