November Happy Hour will be moved to Thursday December 5th.

StarCommunity Caching Issue

Vote:
 

I have added a member in my friend list but i cant see the new added member in my list. It shows me the old list. I suppose the methos is taking the friend list from cache. When i close the browser and reopen it I still cant see the updated list. But when i stop the server and restart it i can see the Updated List

I have also added the functionality to remove the cache after Adding a member but didnot work . Please let me know how can i see the updated list and Total count without restarting the server.

Here is the code to fetch list of members

public ContactRelationCollection GetAllContactRelationFindByName(string userName)
{
ContactRelationQuery query = new ContactRelationQuery();
query.ContactType = new ContactTypeCriterion();
query.ContactType.Value = ContactType.Contact;
query.ContactUser = new UserCriterion();
query.ContactUser.UserName = new StringCriterion();
query.ContactUser.UserName.Value = userName;
query.ContactUser.UserName.WildCardType =WildCardType.Both;
ContactRelationCollection contactRelationCollection = ContactHandler.GetQueryResult(query);
return contactRelationCollection;
}

Code to get Total Contacts

public int GetTotalContacts(int memberId)
{
IUser userA = (IUser)StarCommunitySystem.CurrentContext.DefaultSecurity.GetUser(memberId);
MyPage myPageA = MyPageHandler.GetMyPage(userA);
return myPageA.Contact.GetContacts(ContactType.Contact,Perspective.FromMe, 1,int.MaxValue).Count;

}

Code To clear Cache
void ContactHandler_ContactRelationUpdated(string sender, StarSuite.Core.StarSuiteEventArgs e) {

CacheHandler.RemoveCachedObject((ContactRelationStarCommunity)e.Object).ContactContainer);
CacheHandler.RemoveCachedObject(((ContactRelationStarCommunity)e.Object).CacheKey);
CacheHandler.RemoveCachedObject(((ContactRelationStarCommunity)e.Object).ContactUser);

}

Please Note:  The above issue is very critical so pls help soon

Regards,

Bhavin Chheda 

 

 

#20761
Jun 11, 2008 12:55
Vote:
 

The query cash is invalidaten whenever an object in the result is altered, so new object that would match the query will not show up until the cache has reached its timeout.

Work is beeing done to include a method to manually invalidate the query cash.

Queries are only intended to be used when there are no suitable API calls available. In this case, ContactHandler has a method called GetContacts() which can be used.

#20790
Jun 12, 2008 13:25
Vote:
 

As I told you earlier that i m using GetContacts() to find the count of mycontacts. As you said that  Queries are only intended to be used when there are no suitable API calls available, Than what about the total contacts which i m getting from GetContacts(), which is also not giving me updated count .This method is also taking the result from cache

public int GetTotalContacts(int memberId)
{
IUser userA = (IUser)StarCommunitySystem.CurrentContext.DefaultSecurity.GetUser(memberId);
MyPage myPageA = MyPageHandler.GetMyPage(userA);
return myPageA.Contact.GetContacts(ContactType.Contact,Perspective.FromMe, 1,int.MaxValue).Count;

}

#20815
Jun 13, 2008 11:00
Vote:
 

Hi Bhavin,

GetContacts and ContactQuery are two isolated functionalities and don't share the same cached results.

But the correct updated result should of course be returned from GetContacts. I assume you mean that the count is not updated right after adding a new ContactRelation.

What is important to confirm then is that the ContactRelation actually is of the type ContactType.Contact when adding it. If it is ContactType.Request that means that it will not show up in the result of your method call, since it's not approved yet. Also, when approving a request and then updating it to ContactType.Contact, the relation must be added in the opposite direction too for the receiver to also have the contact in its list, otherwise it's just an approved one way relation.

This is not the case when adding a new relation with the initial state of ContactType.Contact, because of a setting in the contact module configuration telling it to automatically make two way relations for that scenario.

In the programmer's guide under section 2.14.3. Approving a Contact Relation there is an example on two way relations.

#20830
Jun 13, 2008 15:33
Vote:
 

I have already used 2 way conatct relation and in the database i can see the contact has been made

what i told you that unless i close my server the result is not getting updated.

After reopening the server i can see the correct result.

 This proves that Get total contact is taking the value form cache.

Please tell me how to remove cache

for you reference i m giving you two way contact relation code

public void ApproveContactRelation(int memberId, int contactRelationId)
  {

   IUser userA = GetUser(contactRelationId);
   MyPage myPageA = MyPageHandler.GetMyPage(userA);
   IUser userB = GetUser(memberId);
   MyPage myPageB = MyPageHandler.GetMyPage(userB);

   ContactRelationStarCommunity contactRelation = myPageA.Contact.GetContactRelation(userB);

    contactRelation = (ContactRelationStarCommunity)contactRelation.Clone();
    contactRelation.ContactType = ContactType.Contact;
    ContactHandler.UpdateContactRelation(contactRelation);
         

   contactRelation = myPageB.Contact.GetContactRelation(userA);
    contactRelation = (ContactRelationStarCommunity)contactRelation.Clone();
    contactRelation.ContactType = ContactType.Contact;
    ContactHandler.UpdateContactRelation(contactRelation);
    
  }

 

 

 

 

#20835
Jun 14, 2008 9:54
This thread is locked and should be used for reference only. Please use the Legacy add-ons forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.