/// <summary> /// Storring books in cache. Ignite not provide atomic increament easilly accesible so used just guid (I am aware that is considerably bigger than data it is attached to). /// Other approach for this could be: /// - ids reservation per instance /// - id generator with based on long/double etc (to save space) with PutIfAbsent approach /// - ids generation based on instance suffix/prefix /// - auto increment workaround: http://apache-ignite-users.70518.x6.nabble.com/Atomic-Sequence-Auto-Increment-via-IgniteClient-Thin-Client-Ignite-2-8-1-td33005.html /// </summary> /// <param name="book">Book to be stored persistently. Book Id will be updated to new value.</param> /// <returns></returns> public bool StoreBook(ref Book book) { logger.LogInformation("Storring book: {}/{}/{}", book.Author, book.Title, book.PublicationYear); BookKey key; do { book.Id = Guid.NewGuid().ToString(); key = new BookKey { Id = book.Id }; } while (!bookCache.PutIfAbsent(key, book)); return(true); }
private void Awake() { bookkeyScript = FindObjectOfType <BookKey>(); }
protected bool Equals(BookKey other) { return Value == other.Value; }