Skip to content

Commit

Permalink
update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
sunzongtang committed Dec 17, 2019
1 parent 6a56f50 commit 8e606a4
Show file tree
Hide file tree
Showing 10 changed files with 42 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Android-demo/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation project(path: ':mlnkv')

// implementation "com.mlnkv:mlnkv:0.0.1"
}
13 changes: 12 additions & 1 deletion Android-demo/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
//加入bintray-release插件
classpath 'com.novoda:bintray-release:0.9.1'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -18,8 +20,17 @@ allprojects {
repositories {
google()
jcenter()


// maven {url "https://dl.bintray.com/sunzt8801/MLNKV"}
}

// tasks.withType(JavaDoc) {
// options{
// encoding "UTF-8"
// charset "UTF-8"
// links "http://docs.oracle.com/javase/7/docs/api"
// }
// }
}

task clean(type: Delete) {
Expand Down
16 changes: 16 additions & 0 deletions Android-demo/mlnkv/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
apply plugin: 'com.android.library'
apply plugin: 'com.novoda.bintray-release'//添加 bintray-release 配置

android {
compileSdkVersion 29
Expand Down Expand Up @@ -44,3 +45,18 @@ dependencies {
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}


publish {
userOrg = 'sunzt8801'
repoName = 'MLNKV'
groupId = 'com.mlnkv'
artifactId = 'mlnkv'
publishVersion = '0.0.1'
desc = 'MLNKV是基于mmap实现的高性能、内存占用低、跨平台(支持iOS与Android)的Key-Value组件。'
website = 'https://github.com/momotech/MLNKV'
}




Binary file not shown.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ MLNKV *mlnkv = [MLNKV defaultMLNKV];
```
### Android 基本用法<br>

`maven {url "https://dl.bintray.com/sunzt8801/MLNKV"}`<br>
` implementation "com.mlnkv:mlnkv:0.0.1" `
```
// must call this in MainActivity
Expand Down Expand Up @@ -80,7 +81,8 @@ MLNKV mlnkv = MLNKV.defaultMLNKV();
```


# 许可证
MLNKV 使用 MIT 许可证,详情见 LICENSE 文件。



Expand Down
12 changes: 8 additions & 4 deletions Source/iOS/MLNKV.mm
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,10 @@ - (BOOL)setKVString:(NSString *)value forKey:(NSString *)aKey {
if (!value || ![value isKindOfClass:NSString.class]) {
return [self setKVObject:value forKey:aKey];
}
return _kvBase->setString(value.UTF8String, aKey.UTF8String);
NSUInteger length = value.length;
unichar buffer[length];
[value getCharacters:buffer range:NSMakeRange(0, length)];
return _kvBase->setBytes(buffer, length * sizeof(unichar), aKey.UTF8String);
}

- (BOOL)setKVInt32:(int32_t)value forKey:(NSString *)aKey {
Expand Down Expand Up @@ -254,9 +257,10 @@ - (NSString *)getKVStringForKey:(NSString *)aKey {

- (NSString *)getKVStringForKey:(NSString *)aKey defaultValue:(NSString *)defaultValue {
MLNKVGetKeyAssert(nil);
std::string value;
if (_kvBase->getStringForKey(aKey.UTF8String, value)) {
NSString *valueStr = [NSString stringWithUTF8String:value.c_str()];
void *value;
size_t size;
if (_kvBase->getBytesForKey(aKey.UTF8String, value, size)) {
NSString *valueStr = [[NSString alloc] initWithCharacters:(unichar *)value length:size/sizeof(unichar)];
return valueStr;
}
return defaultValue;
Expand Down
Binary file modified img/getString.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/memory.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/setInt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/setString.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8e606a4

Please sign in to comment.