Cassette
An efficient, file-based FIFO Queue for iOS and macOS.
Install / Use
/learn @linkedin/CassetteREADME
Cassette
Cassette is a collection of queue-related classes for iOS and macOS. It is maintained by LinkedIn. Cassette was originally implemented by Segment. Cassette was inspired by Tape.
QueueFile is an efficient, file-based FIFO queue. Addition and removal from an instance is an O(1) operation. Writes are synchronous; data will be written to disk before an operation returns. The queue is intended to be reliable and survive system or process crashes.
Installing the Library
CocoaPods
target 'MyApp' do
pod 'Cassette', '1.0.0-beta3'
end
Manual
Download the latest binary of the library.
Usage
CASObjectQueue works with arbitrary objects that abide by the NSCoding protocol. An CASObjectQueue may be backed by a persistent CASQueueFile, or in memory.
CASObjectQueue<NSNumber *> *queue;
// Persistent ObjectQueue
NSError *error;
queue = [[CASFileObjectQueue alloc] initWithRelativePath:@"Test-File" error:&error];
// In-Memory ObjectQueue
queue = [[CASInMemoryObjectQueue alloc] init];
Add some data to the end of the queue.
NSError *error;
if ([queue add:@1 error:&error]) {
// Success
} else {
NSLog(@"Error: %@", error);
}
Read data at the head of the queue.
// Peek the eldest element. Note that -peek:error: on an empty queue
// returns @[], but on error (e.g., I/O error) it returns nil.
NSNumber *data = [queue peek:1 error:&error].firstObject;
// Peek the eldest `n` elements.
NSArray<NSNumber *> *data = [queue peek:n error:&error];
Remove processed elements.
// Remove the eldest element.
if ([queue pop:1 error:&error]) { ... }
// Remove 'n' elements.
if ([queue pop:n error:&error]) { ... }
// Remove all elements.
if ([queue clearAndReturnError:&error]) { ... }
Related Skills
node-connect
339.5kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
83.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
339.5kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
83.9kCommit, push, and open a PR
