<turbo-stream action="append" target="posts_list"><template>    <div class="postbit" id="127389" data-post-id="127389">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="Fl4m3Ph03n1x" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/Fl4m3Ph03n1x/120/11709_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  Fl4m3Ph03n1x
                    <span class="op-star" title="Thread Starter">
                      <img alt="OP" class="op-star-icon" src="/assets/thread-icons/thread-icon-thread-starter-df91e872.png" />
                    </span>
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Ahh, so we would be trading a  faster insertion for a slower retrieval of information. I get the idea !</p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="127389" data-batch-url="/posts/batch_likers">
                        0
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/make-atomic-updates-on-ets-key/22205/12">Post #11</a>
	                </div>
	            </div>
              <div id="likers-container-127389" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="127389"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-standard-post cat-standard-post" title="Post #11"></div>
  </section>
</div>
    <div class="postbit" id="127473" data-post-id="127473">
  <section>
    <div class="post-wrap">


					<div class="post-header">
		        <div class="user-avatar">
		          <img alt="peerreynders" src="https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/peerreynders/120/5826_2.png" width="120" height="120" />
		        </div>
					
						<div class="user-details">
		          <div class="user-name">
		            <h3>
                  peerreynders
                  </h3>
		          </div>
						
						</div>
					
					</div>

	        <div class="thread-main">
	            <div class="post-body" data-turbo="false">
								<p>Precedent: <a href="https://youtu.be/8mXqxBBvNdk?t=1082" rel="noopener nofollow ugc">https://youtu.be/8mXqxBBvNdk?t=1082</a></p>
<p>Possible problem: Deleting entries (e.g. <code>take</code>) in ETS can be potentially slow (relatively speaking), it’s faster to drop the table and recreate it.</p>
<p>Solution tradeoff: insert into table can fail <em>temporarily</em>. So errors must be caught and insert must be retried later - this can be potentially delegated to a short-lived task process if inserting process cannot afford to be blocked.</p>
<ul>
<li>rename table with <a href="http://erlang.org/doc/man/ets.html#rename-2" rel="nofollow"><code>rename/2</code></a></li>
<li>recreate new table under common, known name</li>
<li>do with the renamed table what needs to be done - for example, entire contents can be retrieved with <code>:ets.tab2list/1</code>, <code>:ets.match_object(tid, {'$0', '$1'})</code>, (don’t know performance relative to <code>:ets.lookup(tid, :failed) </code>).</li>
<li>when done <a href="http://erlang.org/doc/man/ets.html#delete-1" rel="nofollow"><code>delete/1</code></a> renamed table</li>
</ul>
<hr>
<p><a href="https://github.com/evadne/ets-playground" rel="noopener nofollow ugc">ets-playground</a><br>
<a href="https://github.com/duomark/epocxy/blob/master/src/cxy_cache.erl" rel="noopener nofollow ugc">cxy_cache.erl</a></p> 
	            </div>

	            <div class="base-line">
	                <div class="thread-counters">
	                    <span class="thread-count count-likes js-likers-trigger" title="Likes" data-post-id="127473" data-batch-url="/posts/batch_likers">
                        2
                      </span>
                      <!-- <span class="thread-count js-solved-indicator" title="Marked as solution"></span> -->
	                </div>
	                <div class="go-to-post">
	                  <a title="Go to post" alt="Go to post" href="https://forum.elixirforum.com/t/make-atomic-updates-on-ets-key/22205/13">Post #12</a>
	                </div>
	            </div>
              <div id="likers-container-127473" 
                   class="likers-container"
                   data-first-post="false"
                   data-batch-url="/posts/batch_likers">
                   <div class="likers-placeholder" 
                     data-likers-post-id="127473"
                     data-batch-url="/posts/batch_likers">
                  <div class="post-likers"></div>
                </div>
              </div>
	        </div>
			

    </div>

    <div class="triangle-top-right type-last-post cat-last-post" title="Last post!"></div>
  </section>
</div>
</template></turbo-stream><turbo-stream action="replace" target="load-more-container"><template><div id="load-more-container" class="load-more-container">
    <span class="all-loaded">— All posts loaded —</span>
</div></template></turbo-stream>