All Projects → pinterest → Pincache

pinterest / Pincache

Licence: apache-2.0
Fast, non-deadlocking parallel object cache for iOS, tvOS and OS X

Programming Languages

objective c
16641 projects - #2 most used programming language
shell
77523 projects
swift
15916 projects

Projects that are alternatives of or similar to Pincache

Ktvhttpcache
A powerful media cache framework.
Stars: ✭ 2,113 (-15.92%)
Mutual labels:  cache, cocoapods, carthage
Fwplayer
A video player SDK for iOS, it is based on AVPlayer. https://se.linkedin.com/in/foks-huiwang, https://fokswang.wixsite.com/home
Stars: ✭ 321 (-87.23%)
Mutual labels:  cache, cocoapods, carthage
Sdwebimage
Asynchronous image downloader with cache support as a UIImageView category
Stars: ✭ 23,928 (+852.17%)
Mutual labels:  cache, cocoapods, carthage
Swiftdailyapi
A Swift API framework for ZhiHu's Daily News.
Stars: ✭ 204 (-91.88%)
Mutual labels:  cocoapods, carthage
Cocoalumberjack
A fast & simple, yet powerful & flexible logging framework for Mac and iOS
Stars: ✭ 12,584 (+400.76%)
Mutual labels:  cocoapods, carthage
Wkcookiewebview
WKWebView with cookie sharing support
Stars: ✭ 171 (-93.2%)
Mutual labels:  cocoapods, carthage
Bluetoothkit
Easily communicate between iOS/OSX devices using BLE
Stars: ✭ 2,027 (-19.34%)
Mutual labels:  cocoapods, carthage
Whatsnewkit
Showcase your awesome new app features 📱
Stars: ✭ 2,329 (-7.32%)
Mutual labels:  cocoapods, carthage
Icimulator
Simulate camera functions on iOS Simulator with images, videos, or your MacBook Camera.
Stars: ✭ 177 (-92.96%)
Mutual labels:  cocoapods, carthage
Swiftyanimate
Composable animations in Swift
Stars: ✭ 194 (-92.28%)
Mutual labels:  cocoapods, carthage
Tkradarchart
A customizable radar chart in Swift
Stars: ✭ 199 (-92.08%)
Mutual labels:  cocoapods, carthage
Svprogresshud
A clean and lightweight progress HUD for your iOS and tvOS app.
Stars: ✭ 12,339 (+391.01%)
Mutual labels:  cocoapods, carthage
Segmentio
Animated top/bottom segmented control written in Swift.
Stars: ✭ 2,310 (-8.08%)
Mutual labels:  cocoapods, carthage
Theanimation
Type-safe CAAnimation wrapper. It makes preventing to set wrong type values.
Stars: ✭ 214 (-91.48%)
Mutual labels:  cocoapods, carthage
Irldocumentscanner
A drop-in Objective-C ViewController that will Automatically scan a document for you you.
Stars: ✭ 172 (-93.16%)
Mutual labels:  cocoapods, carthage
Multipeer
📱📲 A wrapper for the MultipeerConnectivity framework for automatic offline data transmission between devices
Stars: ✭ 170 (-93.24%)
Mutual labels:  cocoapods, carthage
L10n Swift
Localization of the application with ability to change language "on the fly" and support for plural form in any language.
Stars: ✭ 177 (-92.96%)
Mutual labels:  cocoapods, carthage
Shsearchbar
The search bar that doesn't suck.
Stars: ✭ 206 (-91.8%)
Mutual labels:  cocoapods, carthage
Kvkcalendar
A most fully customization calendar and timeline library for iOS 📅
Stars: ✭ 160 (-93.63%)
Mutual labels:  cocoapods, carthage
Forecastio
A Swift library for the Forecast.io Dark Sky API
Stars: ✭ 164 (-93.47%)
Mutual labels:  cocoapods, carthage

PINCache

CocoaPods Carthage compatible Build status

Fast, non-deadlocking parallel object cache for iOS and OS X.

PINCache is a fork of TMCache re-architected to fix issues with deadlocking caused by heavy use. It is a key/value store designed for persisting temporary objects that are expensive to reproduce, such as downloaded data or the results of slow processing. It is comprised of two self-similar stores, one in memory (PINMemoryCache) and one on disk (PINDiskCache), all backed by GCD and safe to access from multiple threads simultaneously. On iOS, PINMemoryCache will clear itself when the app receives a memory warning or goes into the background. Objects stored in PINDiskCache remain until you trim the cache yourself, either manually or by setting a byte or age limit.

PINCache and PINDiskCache accept any object conforming to NSCoding. Put things in like this:

Objective-C

UIImage *img = [[UIImage alloc] initWithData:data scale:[[UIScreen mainScreen] scale]];
[[PINCache sharedCache] setObject:img forKey:@"image" block:nil]; // returns immediately

Swift

let img = UIImage(data: data, scale:UIScreen.main.scale)
PINCache.shared().setObject(img, forKey: "img")

Get them back out like this:

Objective-C

[[PINCache sharedCache] objectForKeyAsync:@"image" block:^(PINCache *cache, NSString *key, id object) {
    UIImage *image = (UIImage *)object;
    NSLog(@"image scale: %f", image.scale);
}];

Swift

PINCache.shared().object(forKey: "image") { (cache, key, object) in
    if let image = object as? UIImage {
        print("image scale: %f", image.scale)
    }
}

Both PINMemoryCache and PINDiskCache use locks to protect reads and writes. PINCache coordinates them so that objects added to memory are available immediately to other threads while being written to disk safely in the background. Both caches are public properties of PINCache, so it's easy to manipulate one or the other separately if necessary.

Collections work too. Thanks to the magic of NSKeyedArchiver, objects repeated in a collection only occupy the space of one on disk:

Objective-C

NSArray *images = @[ image, image, image ];
[[PINCache sharedCache] setObject:images forKey:@"images"];
NSLog(@"3 for the price of 1: %d", [[[PINCache sharedCache] diskCache] byteCount]);

Swift

// In Swift, Array, String, and Dictionary are all value types.
let images = [image, image, image] as NSArray // Cast to NSArray
PINCache.shared.setObject(images, forKey: "images")
print("3 for the prices of 1: %d", PINCache.shared.diskCache.byteCount)

Installation

Manually

Download the latest tag and drag the PINCache folder into your Xcode project.

Install the docs by double clicking the .docset file under docs/, or view them online at cocoadocs.org

Git Submodule

git submodule add https://github.com/pinterest/PINCache.git
git submodule update --init

CocoaPods

Add PINCache to your Podfile and run pod install.

Carthage

Add the following line to your Cartfile and run carthage update --platform ios. Then follow this instruction of Carthage to embed the framework.

github "pinterest/PINCache"

Requirements

PINCache requires iOS 8.0, tvOS 9.0, watchOS 2.0 or macOS 10.8 and greater.

Contact

Garrett Moon

License

Copyright 2013 Tumblr, Inc. Copyright 2015 Pinterest, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].