https://github.com/ryanleely/fastkv
FastKV is a real-time and high-performance persistent key-value store implemented by mmap. FastKV是由mmap实现的一个高实时性、高性能key-value持久化存储组件。
https://github.com/ryanleely/fastkv
ios key-value mmap objective-c store
Last synced: 9 months ago
JSON representation
FastKV is a real-time and high-performance persistent key-value store implemented by mmap. FastKV是由mmap实现的一个高实时性、高性能key-value持久化存储组件。
- Host: GitHub
- URL: https://github.com/ryanleely/fastkv
- Owner: RyanLeeLY
- License: mit
- Created: 2018-08-10T06:50:20.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2019-09-12T02:39:31.000Z (over 6 years ago)
- Last Synced: 2025-07-21T21:00:23.802Z (11 months ago)
- Topics: ios, key-value, mmap, objective-c, store
- Language: Objective-C
- Homepage:
- Size: 110 KB
- Stars: 182
- Watchers: 5
- Forks: 19
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FastKV
[](https://cocoapods.org/?q=tinypart)
[](https://cocoapods.org/pods/FastKV)
[](https://github.com/RyanLeeLY/TinyPart/blob/master/LICENSE)
[](mail://liyaoxjtu2013@gmail.com)
[](https://twitter.com/liyaoryan)
[中文介绍](https://github.com/RyanLeeLY/FastKV/blob/master/iOS的高性能、高实时性key-value持久化组件.md)
## Usage
```
[[FastKV defaultFastKV] setBool:YES forKey:@"key"];
[[FastKV defaultFastKV] setInteger:1 forKey:@"key"];
[[FastKV defaultFastKV] setObject:@"value" forKey:@"key"];
[[FastKV defaultFastKV] boolForKey:@"key"];
[[FastKV defaultFastKV] integerForKey:@"key"];
[[FastKV defaultFastKV] objectOfClass:NSString.class forKey:@"key"];
```
## Memory Allocation
`FastKV` provides two kinds of memory allocation strategy.
```
typedef NS_ENUM(NSUInteger, FastKVMemoryStrategy) {
FastKVMemoryStrategyDefault = 0,
FastKVMemoryStrategy1,
};
```
**Doubling** `FastKVMemoryStrategyDefault`
```
size_t allocationSize = 1;
while (allocationSize <= neededSize) {
allocationSize *= 2;
}
return allocationSize;
```
**Linear** `FastKVMemoryStrategy1 `
Reference [python list](https://svn.python.org/projects/python/trunk/Objects/listobject.c)
```
size_t allocationSize = (neededSize >> 3) + (neededSize < 9 ? 3 : 6);
return allocationSize + neededSize;
```
## Installation
FastKV is available through [CocoaPods](https://cocoapods.org). To install
it, simply add the following line to your Podfile:
```ruby
pod 'FastKV'
```
## Benchmark
iPhone 8 64G, iOS 11.4
**Time taken of 10,000 write operations, unit: ms**

## Author
yao.li, liyaoxjtu2013@gmail.com
## License
FastKV is available under the [MIT](https://github.com/RyanLeeLY/FastKV/blob/master/LICENSE) license. See the LICENSE file for more info.