Giter VIP home page Giter VIP logo

Comments (11)

irace avatar irace commented on August 18, 2024

There are many occurrences that can cause TMMemoryCache to release memory, such as setting a costLimit or calling any of the following methods (or their asynchronous counterparts). But yes, UIApplicationDidReceiveMemoryWarning will no longer have any effect on TMMemoryCache by default. If you want this behavior in 2.0, you will need to add it yourself using the lines of code you pasted above.

/**
 Removes the object for the specified key. This method blocks the calling thread until the object
 has been removed.

 @param key The key associated with the object to be removed.
 */
- (void)removeObjectForKey:(NSString *)key;

/**
 Removes all objects from the cache that have not been used since the specified date.
 This method blocks the calling thread until the cache has been trimmed.

 @param date Objects that haven't been accessed since this date are removed from the cache.
 */
- (void)trimToDate:(NSDate *)date;

/**
 Removes objects from the cache, costliest objects first, until the <totalCost> is below the specified
 value. This method blocks the calling thread until the cache has been trimmed.

 @param cost The total accumulation allowed to remain after the cache has been trimmed.
 */
- (void)trimToCost:(NSUInteger)cost;

/**
 Removes objects from the cache, ordered by date (least recently used first), until the <totalCost> is below
 the specified value. This method blocks the calling thread until the cache has been trimmed.
 @param cost The total accumulation allowed to remain after the cache has been trimmed.
 */
- (void)trimToCostByDate:(NSUInteger)cost;

/**
 Removes all objects from the cache. This method blocks the calling thread until the cache has been cleared.
 */
- (void)removeAllObjects;

from tmcache.

studentdeng avatar studentdeng commented on August 18, 2024

Thanks for quick reply. I think handle memory warnings is the default behaviour for Cache which is 1.0 before. The 2.0 strategy is a bit unusual. I think it would be better if it is noticed in README.md, not only in release change log.

from tmcache.

irace avatar irace commented on August 18, 2024

The reason it no longer does this is because TMCache can be used in extensions which cannot refer to the shared application.

I will update the README tomorrow.

from tmcache.

segiddins avatar segiddins commented on August 18, 2024

@irace you can still listen for the notification without referencing the shared application?

from tmcache.

irace avatar irace commented on August 18, 2024

Yeah, that's true actually. Not sure why I didn't think of that.

I can put out a new version that adds this back tomorrow. Unfortunately, I guess by semver rules this would mean bumping the library to 3.0 ๐Ÿ˜ž

from tmcache.

segiddins avatar segiddins commented on August 18, 2024

Nah it's a feature, so 2.1 should be sufficient

-Samuel E. Giddins

On May 7, 2015, at 8:53 PM, Bryan Irace [email protected] wrote:

Reopened #85.

โ€”
Reply to this email directly or view it on GitHub.

from tmcache.

irace avatar irace commented on August 18, 2024

Breaks API compatibility though?

from tmcache.

segiddins avatar segiddins commented on August 18, 2024

How?

-Samuel E. Giddins
segiddins.me

On May 7, 2015, at 9:11 PM, Bryan Irace [email protected] wrote:

Breaks API compatibility though?

โ€”
Reply to this email directly or view it on GitHub.

from tmcache.

irace avatar irace commented on August 18, 2024

I would remove the two new public methods I added in 2.0 for telling the cache that the app was backgrounds or that a memory warning occurred.

from tmcache.

segiddins avatar segiddins commented on August 18, 2024

No need to remove them, you can just deprecate them.

-Samuel E. Giddins

On May 7, 2015, at 9:24 PM, Bryan Irace [email protected] wrote:

I would remove the two new public methods I added in 2.0 for telling the cache that the app was backgrounds or that a memory warning occurred.

โ€”
Reply to this email directly or view it on GitHub.

from tmcache.

irace avatar irace commented on August 18, 2024

Fixed in version 2.1.0

from tmcache.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.