Have an option to maintain private variables through updations

let’s say I want to build a query, I want that to be initialized on the boot and on every click it can get first data from the particular query.

This would be a lot easier if I could just have one private variable sustain through updates.

Why does it have to be private?