Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a NSCache for storing folder's articles #508

Merged
merged 10 commits into from Sep 13, 2015

Conversation

barijaona
Copy link
Member

No description provided.

- Reorganized handling of unread count in Database manager
- Creation of articles is performed through the Folder class (this contributes to recenter cache management in Folder class and makes the code more legible)
- Cleanup in Database manager source
- NSCache has no enumerator, so we must setup our own management in order to provide the unread articles
- The keys are stored in a NSMutableOrderedSet (which guarantees its elements are distinct, contrary to an NSMutableArray)
- Contrary to NSMutableDirectory, NSCache does not store keys ; so it seems important that keys are always stored __before__ objects are written to cache
- Fixed an important comment about Database’s arrayOfArticles
- It seems more coherent that Database’s methods are accessed through folder Id rather than through the Folder object
Note the precautions to avoid conflicts between threads who would lead the cache to be accessed in an unstable state.

I don’t realize the conditions which may lead to execution of lines 736 to 739 of Folder.m
But I saw these conditions arise on my earlier tests, at least after a feed refresh was performed under severe memory stress (achieved with a `memory_pressure -l critical` command)
Group folders and smart folders do not guarantee that all articles will have distinct GUIDs
Some folders were marked as cached, while their cacheGuids were empty.
It appears that under heavy memory pressure, NSCache’s -setObject:forKey might immediately release the key. A workaround is copying the key into a distinct object.

I also reverted cachedGuids to be a NSMutableArray, for the sake of simplicity.
josh64x2 added a commit that referenced this pull request Sep 13, 2015
Use a NSCache for storing folder's articles
@josh64x2 josh64x2 merged commit 1c055aa into ViennaRSS:master Sep 13, 2015
@barijaona barijaona deleted the cache-management branch September 15, 2015 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants