Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by JayMZee · Jan 14, 2020 at 03:07 PM · assetbundlecache

Remove cache after being unused

I need to store assetbundle downloaded with UnityWebRequest, so that I don't have to re-download it every time I start the game. However, I want to remove assetbundle, that was not used for certain amount of days. Therefore, I implemented Caching system. Downloading and loading from local storage works fine, but I can't find a way to set timer for deleting assetbundle. I tried Cache.expirationDelay, which seemed as the right way to do it, but it doesn't work as expected. If I create and add a new Cache and set its expirationDelay to e.g. 20, download assetbundle and then restart the app, this code block:

Cache existingCache = Caching.AddCache(existingCachePath); Debug.Log(existingCache.expirationDelay);

Prints default expirationDelay value - 12960000, even though the folder with assetbundle is already created. Is there any other way that I can find out when was the Cache created, or assetbundle most recently downloaded?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Bunny83 · Jan 14, 2020 at 06:07 PM

I haven't really used the Caching class. However the documentation is pretty clear that using AddCache will add a new cache to a list of caches. To get an existing cache you should use something like Caching.GetCacheByPath or Caching.GetCacheAt


If you have already created several caches you might want to use Caching.GetAllCachePaths to see all caches. Just check the Caching class documentation and scroll to the end to see all the available methods / properties.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image JayMZee · Jan 15, 2020 at 02:21 PM 0
Share

The first issue with this approach is it doesn't work like that, at least not for me. If I create multiple directories, in which I create new Cache using Directory.CreateDirectory(newCachePath); newCache = Caching.AddCache(newCachePath); and then I use Caching.GetAllCachePaths, it really shows paths to all created Caches. However, if I restart Play mode (in Editor), and then use Caching.GetAllCachePaths, it returns only default unity cache path, even though I can see all created folders from previous run in Windows File Explorer. But even if this worked as expected, I still wouldn't be able to get cache last access time, to serve my purpose by deciding whether it has been unused long time enough to delete cache with all its files or not.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

122 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Progress when using WWW.LoadFromCacheOrDownload 2 Answers

How to determine validity of cached asset bundle 1 Answer

Can't load objects from asset bundle when using AssetBundle.CreateFromFile 1 Answer

Cannot download large assetbundle with WWW.LoadFromCacheOrDownload on old iOS device 1 Answer

Unauthorized use of Caching API in webplayer 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges