NXP-14847: make MemRepository thread-safe

Also remove rpop, which is not a safe operation (we don't know
what's going to be removed if there's a concurrent rpush).