Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
## Build generated
build/
DerivedData
/.build/

## Various settings
*.pbxuser
Expand All @@ -33,9 +34,6 @@ project.xcworkspace
*.hmap
*.ipa

# Carthage
Carthage/Build

# Ignore changes to our project.xcconfig that gets overridden by the build system
project.xcconfig
*.coverage.txt
31 changes: 31 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// swift-tools-version:5.7
import PackageDescription

let package = Package(
name: "SPTPersistentCache",
platforms: [
.iOS(.v13),
.macOS(.v10_13),
.tvOS(.v13),
.watchOS(.v4),
],
products: [
.library(name: "SPTPersistentCache", targets: ["SPTPersistentCache"]),
],
dependencies: [],
targets: [
.target(
name: "SPTPersistentCache",
path: "Sources",
resources: [.process("Resources/PrivacyInfo.xcprivacy")]
),
.testTarget(
name: "SPTPersistentCacheTests",
dependencies: ["SPTPersistentCache"],
path: "Tests",
resources: [.process("Resources")],
cSettings: [.headerSearchPath("../Sources")]
),
],
swiftLanguageVersions: [.v5]
)
25 changes: 0 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
[![Documentation](https://img.shields.io/cocoapods/metrics/doc-percent/SPTPersistentCache.svg)](http://cocoadocs.org/docsets/SPTPersistentCache/)
[![License](https://img.shields.io/github/license/spotify/SPTPersistentCache.svg)](LICENSE)
[![CocoaPods](https://img.shields.io/cocoapods/v/SPTPersistentCache.svg)](https://cocoapods.org/?q=SPTPersistentCache)
[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
[![Readme Score](http://readme-score-api.herokuapp.com/score.svg?url=https://github.com/spotify/sptpersistentcache)](http://clayallsopp.github.io/readme-score?url=https://github.com/spotify/sptpersistentcache)

Everyone tries to implement a cache at some point in their app’s lifecycle, and this is ours. This is a library that allows people to cache `NSData` with time to live (TTL) values and semantics for disk management.
Expand Down Expand Up @@ -39,25 +38,6 @@ Lastly let CocoaPods do its thing by running:
$ pod install
```

### Carthage
We support [Carthage](https://github.com/Carthage/Carthage) and provide pre-built binary frameworks for all new releases. Start by making sure you have the latest version of Carthage installed, e.g. using [Homebrew](http://brew.sh/):
```shell
$ brew update
$ brew install carthage
```
You will also need to add `SPTPersistentCache` to your `Cartfile`:
```
github "spotify/SPTPersistentCache" ~> 1.1.1
```
After that is all said and done, let Carthage pull in SPTPersistentCache like so:
```shell
$ carthage update
```
Next up, you need to add the framework to the Xcode project of your App. Lastly link the framework with your App and copy it to the App’s Frameworks directory under the “Build Phases”.

## Usage example :eyes:
For an example of this framework's usage, see the demo application `SPTPersistentCacheDemo` in `SPTPersistentCache.xcworkspace`.

### Creating the SPTPersistentCache
It is best to use different caches for different types of data you want to store, and not just one big cache for your entire application. However, only create one `SPTPersistentCache` instance for each cache, otherwise you might encounter anomalies when the two different caches end up writing to the same file.
```objc
Expand Down Expand Up @@ -139,11 +119,6 @@ At Spotify we began to standardise the way we handled images in a centralised wa

Thus we boiled down what we needed in a cache, the key features being TTL on specific pieces of data, disk management to make sure we don't use too much, and protections against data corruption. It also became very useful to separate different caches into separate files (such as images and mp3s), in order to easily measure how much space each item is taking up.

## Tools :hammer:
Having a nice GUI tool to inspect the contents of an `SPTPersistentCache` directory would be nice, so we made one. In this repository we have a project called `SPTPersistentCacheViewer.xcodeproj` which is part of the `SPTPersistentCache.xcworkspace`. When you open it and build it for OS X, you will see a GUI that allows you to inspect the contents of a cache, including individual items TTL and payload size.

<img alt="SPTPersistentCacheViewer" src="SPTPersistentCacheViewer.png">

## Contributing :mailbox_with_mail:
Contributions are welcomed, have a look at the [CONTRIBUTING.md](CONTRIBUTING.md) document for more information.

Expand Down
14 changes: 8 additions & 6 deletions SPTPersistentCache.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "SPTPersistentCache"
s.version = "1.1.1"
s.version = "1.2.0"
s.summary = "SPTPersistentCache is a fast, binary, LRU cache used in the Spotify iOS app"

s.description = <<-DESC
Expand All @@ -10,8 +10,10 @@ Pod::Spec.new do |s|
with TTL values and semantics for disk management.
DESC

s.ios.deployment_target = "8.0"
s.osx.deployment_target = "10.10"
s.ios.deployment_target = "13.0"
s.tvos.deployment_target = "13.0"
s.osx.deployment_target = "10.13"
s.watchos.deployment_target = "4.0"

s.homepage = "https://github.com/spotify/SPTPersistentCache"
s.social_media_url = "https://twitter.com/spotifyeng"
Expand All @@ -21,11 +23,11 @@ Pod::Spec.new do |s|
}

s.source = { :git => "https://github.com/spotify/SPTPersistentCache.git", :tag => s.version }
s.source_files = "include/SPTPersistentCache/*.h", "Sources/**/*.{h,m,c}"
s.public_header_files = "include/SPTPersistentCache/*.h"
s.source_files = "Sources/**/*.{h,m,c}"
s.public_header_files = "Sources/include/*.{h,m,c}"
s.xcconfig = {
"OTHER_LDFLAGS" => "-lObjC"
}
s.resource_bundle = { 'SPTPersistentCache_Privacy' => ['Resources/PrivacyInfo.xcprivacy'] }
s.resource_bundle = { 'SPTPersistentCache_Privacy' => ['Sources/Resources/PrivacyInfo.xcprivacy'] }

end
Loading
Loading