You're describing an "Electropermanent Magnet". Google the "OpenGrab" and you'll have what you're looking for.