Ultrafast tristable spin memory of a coherent polariton gas