Search Unity

Question Any reason not to use "Cache Clear Behavior = Clear When When New Version Loaded"?

Discussion in 'Addressables' started by Peter77, Aug 17, 2021.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    This is probably a dumb question, but why or when shouldn't I use the "Clear When When New Version Loaded" setting?

    My thought on this is when a new bundle was downloaded, the old bundle isn't needed anymore. When the old bundle is kept, it causes the "app size" on the device to grow for no beneficial reason.

    What am I missing?
    1. When should I use "Clear When When New Version Loaded"?
    2. When should I use "Clear When Space Is Needed In Cache"?
     
    phobos2077 likes this.
  2. CineTek

    CineTek

    Joined:
    Jul 12, 2013
    Posts:
    98
    Okay, watching this thread for insight. We have been using "clear when new version is loaded" exclusively so far as the other setting did not work with our remote addressables content updates at all..
     
  3. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,609
    I would actually like to hear some thoughts from the developers on it. @TreyK-47
     
    CineTek likes this.
  4. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,820
    I'll kick this to the team for some insight!
     
    CineTek likes this.
  5. sniffle63

    sniffle63

    Joined:
    Aug 31, 2013
    Posts:
    365
    I switched to clear on new version today. Couldn't see a reason I wouldn't want it.

    The main reason being, I don't see a way for it to even use the previous versions if I wanted too without explicitly loading an older version of the catalog
     
    Last edited: Oct 5, 2021
  6. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    763
    Hey all, just wanted to say that typically you would want to use "Clear When When New Version Loaded". The main reason you might not want to use it is if you were in a performance critical area of code. The engine side clearing of the cache is synchronous.

    But, as far as "why isn't this the default", it mainly has to do with us our aversion to changing pre-existing default behaviors. We try to make sure we're not going to break expected behavior if a user upgrades.

    In regards to the other version not working after doing a content update I'd have to see what your Caching settings were. By default, the Cache is an LRU cache. It could be that the engine side Caching still thought there was room and so didn't eject anything, or perhaps some files were getting ejected but not the older version of Bundle A, but instead it was Bundle C (which could be still valid) but just hadn't been used in a very long time.
     
    Peter77 likes this.