There are devices called “supercapacitors” that work a little bit like this. They have rather weird electrical characteristics. I think they’re occasionally used as car starter batteries, but they’re mostly used as very long-lasting devices that can store a moderate amount of energy for backup use. I have a nifty DIMM with some supercapacitors that power a circuit that will wrote the contents back to flash if the power fails.