Found solution for iterating through cache and session objects with variable types