How to retrieve variable definition but not from cache?

I am actually exploring how difficult it would be to implement some push/pop commands for CMake variables.
And to make it simpler for me I thought about these commands taking an option determining what kind of variable to push/pop (e.g. something like push(VARIABLE <VAR> ...) and push(CACHE_VARIABLE <VAR> ...)).

Currently, I am at the point where I want to retrieve the old value to save it (the push). How and where this actually should be stored, I haven’t thought through yet. (I thought about storing these variables and their value under some other name but there might even be a better mechanism, by opening another scope or so. I currently do not know what CMake’s C++ code already provides there.)

@robert.maynard Do you think these commands would be something useful for CMake or would you prefer to provide such functionality as a CMake-Module? (I actually think it would be even easier for me to implement this as a CMake-Module, as I do not know the CMake C++ code too well.)