Hi Dustin,<br><br>I'm calling MemcachedClient from inside a webapp under Tomcat 5.5, and it is definitely being hit from multiple clients (multiple threads) at the same time. I don't have assertions enabled. Here's how I'm calling MemcachedClient:
<br><br>constructing:<br> memcache = new MemcachedClient(new InetSocketAddress(host, port));<br><br>Get from cache:<br>private Map<String, Object> getStuff(Collection<Integer> ids) {<br> StringBuilder buf = new StringBuilder(500);
<br> for (int id : ids) {<br> buf.append("cacheditem:").append(id).append(' ');<br> }<br> String request = buf.toString().trim();<br> Map<String, Object> map = memcache.getBulk(request);
<br> log.debug("Requested "+ids.size()+" items from cache, got "+map.size()+" items back");<br> return map;<br>}<br><br><br>Put items in the cache:<br>public void putInCache(Collection<MyItem> itemsToCache, Map<Integer, Long> itemLastmodifiedDates) {
<br> for (MyItem j : itemsToCache) {<br> int id = j.getId();<br> String cachedItemKey = "cacheditem:" + jobId;<br> memcache.set(cachedItemKey, 0, j);<br> Long lastModifiedDate = itemLastmodifiedDates.get
(id);<br> if (lastModifiedDate == null)<br> throw new IllegalArgumentException("itemLastmodifiedDate not found in map for id "+id);<br> memcache.set("itemlastmodified:" + id, 0, lastModifiedDate);
<br> }<br>}<br><br><br>Delete items from cache (when items are updated in the DB):<br>private void delete(int id) {<br> log.debug("Deleting id "+id);<br> String key = Integer.toString(id);<br> memcache.delete
("cacheditem:" + key);<br> memcache.delete("itemlastmodified:" + key);<br>}<br><br><br>That's the bulk of it.. there's a bit more to deal with items that have been updated in the database, and it then removes those items from the cache, which is why I'm storing the lastmodified date for each item.
<br><br>Let me know if you want me to try anything, add logging statements, etc. Thanks,<br><br>Chris<br><br><br><div><span class="gmail_quote">On 10/15/07, <b class="gmail_sendername">Dustin Sallings</b> <<a href="mailto:dustin@spy.net" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
dustin@spy.net</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div><span><br><div><div>On Oct 14, 2007, at 19:06, Chris Lamprecht wrote:
</div><br><blockquote type="cite"><span style="border-collapse: separate; border-spacing: 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-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
public void gotData(String key, int flags, byte[] data) {<br> Collection<GetOperation.Callback> cbs=callbacks.get(key);<br> assert cbs != null : "No callbacks for key " + key;<br> for(GetOperation.Callback
c : cbs) { <---- NPE here<br> c.gotData(key, flags, data);<br> }<br>}<br><br>Any ideas? I haven't dug into the code yet to try and debug it. Also previously I tried the 1.4 client version and got an NPE in
OptimizeGet.java or something like that. Thanks<br></span></blockquote></div><div><br></div></span><div><span style="white-space: pre;">        </span>Are you running with assertions enabled?</div><div><br></div><div><span style="white-space: pre;">
        </span>Can you describe what kinds of operations you have running through this? I've never seen that assertion fire nor had an NPE there, so I'd be curious how much you could tell me about what may have led to this state.
</div><br><div> <span style="border-collapse: separate; border-spacing: 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-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;">
<div>-- </div><div>Dustin Sallings</div><br></span> </div><br></div></blockquote></div><br>