Skip to content

Commit af8b5e7

Browse files
committed
update readme
1 parent 2f26742 commit af8b5e7

File tree

3 files changed

+77
-2
lines changed

3 files changed

+77
-2
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,4 @@ fastlane/Preview.html
6161
fastlane/screenshots/**/*.png
6262
fastlane/test_output
6363
.DS_Store
64+
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata

README.md

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,54 @@
1-
# MemoryMap
1+
2+
# Welcome to MemoryMap! 🚀
3+
4+
[![License](https://img.shields.io/badge/license-MIT-green.svg)](https://opensource.org/licenses/MIT)
5+
[![Swift](https://img.shields.io/badge/Swift-5.5-orange.svg)](https://swift.org/)
6+
[![Platform](https://img.shields.io/badge/platform-iOS%20%7C%20macOS%20%7C%20tvOS%20%7C%20watchOS%20%7C%20visionOS-lightgrey.svg)]()
7+
8+
MemoryMap is a Swift utility class designed for efficient persistence and crash-resilient storage of Plain Old Data (POD) structs using memory-mapped files. It provides thread-safe access to the stored data, ensuring integrity and performance for applications requiring low-latency storage solutions.
9+
10+
## 🌟 Features
11+
12+
- **Memory-mapped file support**: Back a POD struct with a memory-mapped file for direct memory access.
13+
- **Thread-safe access**: Read and write operations are protected by a locking mechanism.
14+
- **Crash resilience**: Changes are immediately reflected in the memory-mapped file.
15+
- **Data integrity validation**: Validates the file using a magic number.
16+
17+
## 🔧 Installation
18+
19+
To get started with MemoryMap, integrate it directly into your project:
20+
21+
1. In Xcode, select **File** > **Swift Packages** > **Add Package Dependency...**
22+
2. Enter the repository URL `https://github.com/naftaly/memorymap.git`.
23+
3. Specify the version or branch you want to use.
24+
4. Follow the prompts to complete the integration.
25+
26+
## 🚀 Usage
27+
28+
```swift
29+
import MemoryMap
30+
31+
struct MyData {
32+
var counter: Int
33+
var flag: Bool
34+
}
35+
36+
do {
37+
let fileURL = URL(fileURLWithPath: "/path/to/memory.map")
38+
let memoryMap = try MemoryMap<MyData>(fileURL: fileURL)
39+
40+
// Read/write data
41+
memoryMap.get.counter = 42
42+
memoryMap.get.flag = false
43+
} catch {
44+
print("Error initializing MemoryMap: \(error)")
45+
}
46+
```
47+
48+
## 👋 Contributing
49+
50+
Got ideas on how to make MemoryMap even better? We'd love to hear from you! Feel free to fork the repo, push your changes, and open a pull request. You can also open an issue if you run into bugs or have feature suggestions.
51+
52+
## 📄 License
53+
54+
MemoryMap is proudly open-sourced under the MIT License. Dive into the LICENSE file for more details.

Sources/MemoryMap/MemoryMap.swift

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,26 @@
1+
/// MIT License
2+
///
3+
/// Copyright (c) 2024 Alexander Cohen
4+
///
5+
/// Permission is hereby granted, free of charge, to any person obtaining a copy
6+
/// of this software and associated documentation files (the "Software"), to deal
7+
/// in the Software without restriction, including without limitation the rights
8+
/// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
/// copies of the Software, and to permit persons to whom the Software is
10+
/// furnished to do so, subject to the following conditions:
11+
///
12+
/// The above copyright notice and this permission notice shall be included in all
13+
/// copies or substantial portions of the Software.
14+
///
15+
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
/// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
/// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
/// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
/// SOFTWARE.
22+
123
import Foundation
2-
import Darwin
324
import os
425

526
/// MemoryMap is a utility class that backs a Plain Old Data (POD) struct

0 commit comments

Comments
 (0)