-
1. Re: About the new chapter Caching in documentation.
seto Feb 27, 2007 9:05 AM (in response to seto)My misunderstanding or the mistake of the doc?
It's like below before:
@Name("chatroom")
public class Chatroom {
@In PojoCache pojoCache;
public void join(String username) {
try
{
Set userList = (Set) pojoCache.get("chatroom", "userList");
if (users==null)
{
userList = new HashSet();
pojoCache.put("chatroom", "users", username);
}
}
catch (CacheException ce)
{
throw new RuntimeException(ce);
}
}
} -
2. Re: About the new chapter Caching in documentation.
gavin.king Feb 27, 2007 10:13 AM (in response to seto)No, JBossCache has automagic dirty checking.
-
3. Re: About the new chapter Caching in documentation.
seto Feb 27, 2007 10:46 AM (in response to seto)I means the users field and the userList filed. The users field isn't defined. Do the userList and users represent different?
-
4. Re: About the new chapter Caching in documentation.
gavin.king Feb 27, 2007 11:02 AM (in response to seto)Yes, users should be userList.
-
5. Re: About the new chapter Caching in documentation.
seto Feb 27, 2007 11:13 AM (in response to seto)AND is the join method to add user in the userList? Why "pojoCache.put("chatroom", "users", username)"? Why not add the username to the set?
-
6. Re: About the new chapter Caching in documentation.
gavin.king Feb 27, 2007 11:21 AM (in response to seto)What if this is the first time? What if there is no Set there yet?
-
7. Re: About the new chapter Caching in documentation.
seto Feb 27, 2007 11:27 AM (in response to seto)If it is the later time, just get the userList as the try scope varible, and do nothing?
So I suppose it as below.
if (userList==null)
{
userList = new HashSet();
}
userList.add(username);
pojoCache.put("chatroom", "userList", userList); -
8. Re: About the new chapter Caching in documentation.
gavin.king Feb 27, 2007 11:32 AM (in response to seto)OK, the code should be:
@Name("chatroom") public class Chatroom { @In PojoCache pojoCache; public void join(String username) { try { Set<String> userList = (Set<String>) pojoCache.get("chatroom", "userList"); if (userList==null) { userList = new HashSet<String>(); pojoCache.put("chatroom", "userList", userList); } userList.put(username); } catch (CacheException ce) { throw new RuntimeException(ce); } } }
-
9. Re: About the new chapter Caching in documentation.
seto Feb 27, 2007 11:38 AM (in response to seto)OK, thanks. I finally understand your words "JBossCache has automagic dirty checking".