Add write methods for repositories

and implement the new methods in the MemoryStore