Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 518721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:57:58+00:00 2026-05-13T07:57:58+00:00

Say I have Object A which has a member of type Object B.. and

  • 0

Say I have Object A which has a member of type Object B.. and Object B has a member of type Object C.

Object A VERY RARELY changes but is read very frequently, whereas Object C frequently does. It makes sense to cache Object A, but when it’s serialized to go in the cache obviously is serialized the whole graph.

Scenario:
Object A is read from the database and populated. Variable of type Object C is accessed and lazy loaded. For the sake of example C.Status is referenced in business logic, and has the value ACTIVE. I change A.Name to be “New Name”, and commit to the database and my cache.

Object C (from somewhere else in code) has it’s status changed to SUSPEND.

  • At this point should I invalidate the cache of Object A? *

If I do:

If (A.B.C.Status == ACTIVE)
SendLotsOfMoney(A)

This will pass, because the whole graph is serialized.

If C.Status changes frequently I don’t want to keep invalidating the cache of A because I might be frequently referring to A.Name, A.Status etc, and do not want to keep hitting the database.

I guess my options are:
1) Have a flag in the object to day that it’s come from cache, and force reload all of the dependencies the first time if it has and they are referenced (lazy load them again). These might come from cache anyway.. but there is still a lot of pointlessly stored data in my cache then.

2) Keep invalidating the cache. Obviously if I have A.B.C.D.E.F.G.Status, and A.H.I.J.K.Status etc, then I’m going to be recreating A all the time?

3) I override OnDeserialization and do what is in (1)

4) I override OnSerialization and set all references to be null (so they are lazy loaded and not stored?)

I’m interested to hear the responses. I’m leaning towards 4

Regards!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:57:58+00:00Added an answer on May 13, 2026 at 7:57 am

    Do you have a way to change the reference to C in A.B to null when C changes? Then rather than invalidating all of A, you just set the C reference to null and lazy-load it again when you need it.

    Or, you could cache C separately from A and B. In A.B instead of a reference to C, you could keep a cache key. You could then invalidate C whenever you need to, and use the cache key to retrieve and/or lazy-load it,

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a Car object which also has an Engine member, and
Say I have a model object 'Person' defined, which has a field called 'Name'.
Let's say I have a WCF service which has a method returning object Person.
Let's say we have a template class Area , which has a member variable
Lets say I have object Tom which has class Person. Class Person String Name
Say I have a Timer object which has a TimerDisplay object as one of
Say I have an object called MyClass, which has a property defined as @property
Say I have a list of member, each of which is a custom object:
In C#,I have an object say Shape which has two fields area and length
Say I have a simple object which supports implicit casting to System.String public sealed

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.