<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">
Sure thing.<div><br class="webkit-block-placeholder"></div><div>I am not sure if a binary tree could help the situation, was wondering if it could and how to implement if possible. Scenario:</div><div><br></div><div>1) User A visits website 1 time within hour (1). Object should only be created 1 time for the hour (we did this based on simple counter system and the website id).</div><div><div>2) User B visits website 1 time within hour (1). Object created.</div><div>3) User A visits website 1 time within hour (2). Object created.</div><div>4) User B visited website 1 time within hour (2). Object created.</div><div>5) User C visited website 1 time within hour (2). Object created.</div><div><br class="webkit-block-placeholder"></div><div>The list should only show last 3 visitors to the site (unique) at any one time. Last object being first:</div><div> - User C</div><div> - User B</div><div> - User A</div><div><br class="webkit-block-placeholder"></div><div>There is a possibility that a site could have no traffic for hours, and a user visits it each hour, so the list could have a user multiple times (spread by hour) since were only limiting it by the hour and we do want it to be unique. So what I am wondering is, how could we potentially get around this issue by avoiding locks? We thought about just storing an array for a site of last 10 users, then using array push/pop methods on it and use a lock method. But wouldn't a lock potentially delay the script executing until the lock is available (slowing down the execution time) ?</div><div><br class="webkit-block-placeholder"></div></div><div><div contenteditable="false"><span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div>-Chris</div><br class="Apple-interchange-newline"></span> </div><br><div><div>On Sep 7, 2007, at 2:55 PM, dormando wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br><blockquote type="cite">In this case we would only just want to show User A one time especially since its a list of user activity. We can't store a hash and just push/pop because of race conditions (our first thought). If anyone has any ideas, I'd really appreciate it!<br></blockquote><br>I don't follow :( Could you try explaining what the problem is in more detail, and how a binary tree setup would be better than a one time lock?<br><br>I don't really see the above example being a problem even if there is a race condition.<br><br>-Dormando<br></blockquote></div><br></div></body></html>