Skip to content

Commit

Permalink
Merge pull request #60 from cmushroom/dev
Browse files Browse the repository at this point in the history
2.5.2
  • Loading branch information
chengpan168 authored May 21, 2023
2 parents 4e57066 + 653f164 commit b61e135
Show file tree
Hide file tree
Showing 28 changed files with 268 additions and 89 deletions.
6 changes: 3 additions & 3 deletions .version
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"latestVersionNum": 20,
"latestVersion": "2.5.1",
"latestVersionNum": 22,
"latestVersion": "2.5.2",
"updateType": "hint",
"releaseNotes": "1. 修复低版本用户名问题。"
"releaseNotes": "1. 增加字符串长度查询设置,对于超长字符通守getrange改善性能。\n2. 优化线程池关闭方式。"
}
22 changes: 11 additions & 11 deletions redis-pro.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
4382204026574E3F00DA7F9E /* MSpin.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4382203F26574E3F00DA7F9E /* MSpin.swift */; };
43822042265763D400DA7F9E /* RedisProCommands.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43822041265763D400DA7F9E /* RedisProCommands.swift */; };
4385D32E261ED26200BA8ED1 /* IndexView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4385D32D261ED26200BA8ED1 /* IndexView.swift */; };
4397288C2643E43800803BE9 /* Constants.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4397288B2643E43800803BE9 /* Constants.swift */; };
4397288C2643E43800803BE9 /* Const.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4397288B2643E43800803BE9 /* Const.swift */; };
43BB012326390BC20039565E /* ModalView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43BB012226390BC20039565E /* ModalView.swift */; };
43BCCD3526A919B8000BE45F /* MSecureField.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43BCCD3426A919B8000BE45F /* MSecureField.swift */; };
43BCCD3726A91E85000BE45F /* FormItemPassword.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43BCCD3626A91E85000BE45F /* FormItemPassword.swift */; };
Expand Down Expand Up @@ -131,7 +131,7 @@
627E1BC4282F462C00163D6B /* RenameStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 627E1BC3282F462C00163D6B /* RenameStore.swift */; };
627E1BC6282FC72B00163D6B /* HashValueStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 627E1BC5282FC72B00163D6B /* HashValueStore.swift */; };
627E1BC8282FCEE300163D6B /* ScanStore.swift in Sources */ = {isa = PBXBuildFile; fileRef = 627E1BC7282FCEE300163D6B /* ScanStore.swift */; };
6280596828B218D800126E81 /* RediStackClientString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6280596728B218D800126E81 /* RediStackClientString.swift */; };
6280596828B218D800126E81 /* RedisClientString.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6280596728B218D800126E81 /* RedisClientString.swift */; };
6280596A28B23DBB00126E81 /* RediStackClientStream.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6280596928B23DBB00126E81 /* RediStackClientStream.swift */; };
628F9AA02896A3FB0003B6C0 /* RedisCommandExt.swift in Sources */ = {isa = PBXBuildFile; fileRef = 628F9A9F2896A3FB0003B6C0 /* RedisCommandExt.swift */; };
628F9AA2289EA7C50003B6C0 /* SSHTunnel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 628F9AA1289EA7C50003B6C0 /* SSHTunnel.swift */; };
Expand Down Expand Up @@ -267,7 +267,7 @@
4382203F26574E3F00DA7F9E /* MSpin.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MSpin.swift; sourceTree = "<group>"; };
43822041265763D400DA7F9E /* RedisProCommands.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RedisProCommands.swift; sourceTree = "<group>"; };
4385D32D261ED26200BA8ED1 /* IndexView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = IndexView.swift; sourceTree = "<group>"; };
4397288B2643E43800803BE9 /* Constants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Constants.swift; sourceTree = "<group>"; };
4397288B2643E43800803BE9 /* Const.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Const.swift; sourceTree = "<group>"; };
43BB012226390BC20039565E /* ModalView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ModalView.swift; sourceTree = "<group>"; };
43BCCD3426A919B8000BE45F /* MSecureField.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MSecureField.swift; sourceTree = "<group>"; };
43BCCD3626A91E85000BE45F /* FormItemPassword.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FormItemPassword.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -331,7 +331,7 @@
627E1BC3282F462C00163D6B /* RenameStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RenameStore.swift; sourceTree = "<group>"; };
627E1BC5282FC72B00163D6B /* HashValueStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HashValueStore.swift; sourceTree = "<group>"; };
627E1BC7282FCEE300163D6B /* ScanStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScanStore.swift; sourceTree = "<group>"; };
6280596728B218D800126E81 /* RediStackClientString.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RediStackClientString.swift; sourceTree = "<group>"; };
6280596728B218D800126E81 /* RedisClientString.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RedisClientString.swift; sourceTree = "<group>"; };
6280596928B23DBB00126E81 /* RediStackClientStream.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RediStackClientStream.swift; sourceTree = "<group>"; };
628F9A9F2896A3FB0003B6C0 /* RedisCommandExt.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RedisCommandExt.swift; sourceTree = "<group>"; };
628F9AA1289EA7C50003B6C0 /* SSHTunnel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SSHTunnel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -560,7 +560,7 @@
62D1BA9428435C0C00F41CAD /* Helpers */,
431266D7261C66E100FB6B69 /* MTheme.swift */,
4373C50025C2E75B002B700E /* BizError.swift */,
4397288B2643E43800803BE9 /* Constants.swift */,
4397288B2643E43800803BE9 /* Const.swift */,
437BC2442645272E00E2C84D /* DoubleFormatter.swift */,
437BC24626452AE400E2C84D /* StringFormatter.swift */,
43CD286D2670A03800E11876 /* VersionManager.swift */,
Expand Down Expand Up @@ -638,7 +638,7 @@
isa = PBXGroup;
children = (
4314A34E2625B46E00053FEE /* RediStackClient.swift */,
6280596728B218D800126E81 /* RediStackClientString.swift */,
6280596728B218D800126E81 /* RedisClientString.swift */,
620AF6B727D486F5002D6895 /* RedisClientScan.swift */,
620AF6B527D485EB002D6895 /* RedisClientKeys.swift */,
620AF6B927D48848002D6895 /* RedisClientHash.swift */,
Expand Down Expand Up @@ -972,7 +972,7 @@
436BB6932644D126008B4866 /* SetEditorView.swift in Sources */,
4373C50525C3F0B6002B700E /* UserDefaultsKeysEnum.swift in Sources */,
4340E2CA2666494300F51F19 /* ScanModel.swift in Sources */,
4397288C2643E43800803BE9 /* Constants.swift in Sources */,
4397288C2643E43800803BE9 /* Const.swift in Sources */,
620AF6C627D48996002D6895 /* RedisClientSlowLog.swift in Sources */,
62BDAB3E293B7C0000ADA406 /* AbountCommand.swift in Sources */,
43F22F1326A5546000A00F97 /* RedisInfoItemModel.swift in Sources */,
Expand All @@ -995,7 +995,7 @@
4382204026574E3F00DA7F9E /* MSpin.swift in Sources */,
626C4C622820376700B7A542 /* RedisFavoriteDefaultSelectTypeEnum.swift in Sources */,
62D741C1288415180049AB3C /* LuaStore.swift in Sources */,
6280596828B218D800126E81 /* RediStackClientString.swift in Sources */,
6280596828B218D800126E81 /* RedisClientString.swift in Sources */,
62D741B9284B776D0049AB3C /* RedisConfigStore.swift in Sources */,
62E9F13F2849DA9F00F4FABF /* SystemEnvironment.swift in Sources */,
627E1BC8282FCEE300163D6B /* ScanStore.swift in Sources */,
Expand Down Expand Up @@ -1400,7 +1400,7 @@
repositoryURL = "https://github.com/apple/swift-log.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.4.2;
minimumVersion = 1.5.2;
};
};
625B41B7293AEBD700C7766D /* XCRemoteSwiftPackageReference "RediStack" */ = {
Expand Down Expand Up @@ -1432,15 +1432,15 @@
repositoryURL = "https://github.com/sushichop/Puppy.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 0.6.0;
minimumVersion = 0.7.0;
};
};
CEA1EF48277C56B100D300E9 /* XCRemoteSwiftPackageReference "swift-nio-ssh" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/apple/swift-nio-ssh";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 0.4.1;
minimumVersion = 0.6.1;
};
};
CEA1EF4B277C56DD00D300E9 /* XCRemoteSwiftPackageReference "swift-nio" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/sushichop/Puppy.git",
"state" : {
"revision" : "9f3cf02dc92bc233e40ba8a66af20abb97978929",
"version" : "0.6.0"
"revision" : "b5af02a72a5a1f92a68e6eceee19cac804067ad9",
"version" : "0.7.0"
}
},
{
Expand Down Expand Up @@ -113,8 +113,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "6fe203dc33195667ce1759bf0182975e4653ba1c",
"version" : "1.4.4"
"revision" : "32e8d724467f8fe623624570367e3d50c5638e46",
"version" : "1.5.2"
}
},
{
Expand All @@ -140,8 +140,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-ssh",
"state" : {
"revision" : "fe02717fa9f7eb8d82957d6784bc3d1793f9c1e6",
"version" : "0.4.1"
"revision" : "baa05dc6ff3de89c589a9d582659f0f6699f62ab",
"version" : "0.6.1"
}
},
{
Expand Down
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@
filePath = "redis-pro/Common/RedisClient/RediStackClient.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "208"
endingLineNumber = "208"
startingLineNumber = "204"
endingLineNumber = "204"
landmarkName = "getConnPool()"
landmarkType = "7">
</BreakpointContent>
Expand All @@ -78,11 +78,43 @@
filePath = "redis-pro/Common/RedisClient/RediStackClient.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "218"
endingLineNumber = "218"
startingLineNumber = "214"
endingLineNumber = "214"
landmarkName = "getConnPool()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "9F37F7B6-4F02-4922-9B0C-FB9C989BB8C3"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "../../../Library/Developer/Xcode/DerivedData/redis-pro-dqdhwgmlxxtepdhgbmpmdcldlrxf/SourcePackages/checkouts/RediStack/Sources/RediStack/RedisConnectionPool.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "339"
endingLineNumber = "339"
landmarkName = "send(_:eventLoop:logger:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "7112FABA-02DE-405D-9BE2-5C1ED226609E"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "redis-pro/Common/RedisClient/RedisClientString.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "42"
endingLineNumber = "42"
landmarkName = "getRange(_:start:end:)"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,38 @@
endingLineNumber = "46"
landmarkName = "getSSHConnection()"
landmarkType = "7">
<Locations>
<Location
uuid = "9D39A2D8-B6EA-4BD7-A77B-0FEEF357806F - 6ba00c96e1fac648"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "closure #1 (Swift.UnsafeContinuation&lt;RediStack.RedisConnection, Swift.Error&gt;) -&gt; () in redis_pro.RediStackClient.getSSHConn() async throws -&gt; RediStack.RedisConnection"
moduleName = "redis-pro"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/chengpanwang/work/redis-pro/redis-pro/Common/SSH/SSHRediStackClient.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "47"
endingLineNumber = "47"
offsetFromSymbolStart = "1849">
</Location>
<Location
uuid = "9D39A2D8-B6EA-4BD7-A77B-0FEEF357806F - 6ca25af5c6119117"
shouldBeEnabled = "Yes"
ignoreCount = "0"
continueAfterRunningActions = "No"
symbolName = "closure #2 @Sendable (Swift.Error) -&gt; () in closure #1 (Swift.UnsafeContinuation&lt;RediStack.RedisConnection, Swift.Error&gt;) -&gt; () in redis_pro.RediStackClient.getSSHConn() async throws -&gt; RediStack.RedisConnection"
moduleName = "redis-pro"
usesParentBreakpointCondition = "Yes"
urlString = "file:///Users/chengpanwang/work/redis-pro/redis-pro/Common/SSH/SSHRediStackClient.swift"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "48"
endingLineNumber = "48"
offsetFromSymbolStart = "80">
</Location>
</Locations>
</BreakpointContent>
</BreakpointProxy>
<BreakpointProxy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@
<dict>
<key>SchemeUserState</key>
<dict>
<key>CustomDump (Playground) 1.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>20</integer>
</dict>
<key>CustomDump (Playground) 2.xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>21</integer>
</dict>
<key>CustomDump (Playground).xcscheme</key>
<dict>
<key>isShown</key>
<false/>
<key>orderHint</key>
<integer>19</integer>
</dict>
<key>Playground (Playground) 1.xcscheme</key>
<dict>
<key>isShown</key>
Expand Down
2 changes: 1 addition & 1 deletion redis-pro/Command/HomeCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ struct HomeCommands: View {

var body: some View {
Button("Home") {
guard let url = URL(string: Constants.REPO_URL) else {
guard let url = URL(string: Const.REPO_URL) else {
return
}
openURL(url)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
//
// Constants.swift
// Const.swift
// redis-pro
//
// Created by chengpanwang on 2021/5/6.
//

import Foundation

struct Constants {
struct Const {
static let EMPTY_STRING = ""

static let LIST_VALUE_DELETE_MARK = "__REDIS_LIST_VALUE_DELETE_BY_REDIS_PRO__"

static let REPO_URL = "https://github.com/cmushroom/redis-pro"
static let RELEASE_URL = "https://github.com/cmushroom/redis-pro/releases"

// 最大字符串展示长度默认值
static let DEFAULT_STRING_MAX_LENGTH = 10240
}
2 changes: 1 addition & 1 deletion redis-pro/Common/PuppyLogger.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ final class LogFormatter: LogFormattable {
func formatMessage(_ level: LogLevel, message: String, tag: String, function: String,
file: String, line: UInt, swiftLogInfo: [String : String],
label: String, date: Date, threadID: UInt64) -> String {
let date = dateFormatter(date, dateFormat: "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
let date = dateFormatter(date, withFormatter: .init(), dateFormat: "yyyy-MM-dd'T'HH:mm:ss.SSSZ")
let file = fileName(file)
return "\(date) [\(level.emoji) \(level)] \(file)#L.\(line) \(function) \(message)"
}
Expand Down
15 changes: 4 additions & 11 deletions redis-pro/Common/RedisClient/RediStackClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ import NIOSSH
import Swift
import ComposableArchitecture

class Cons {
static let EMPTY_STRING = ""
}

class RediStackClient {
let logger = Logger(label: "redis-client")
var redisModel:RedisModel
Expand Down Expand Up @@ -114,7 +110,7 @@ class RediStackClient {
conn.send(command, eventLoop: nil, logger: self.logger)
.whenComplete({completion in
if case .success(let r) = completion {
self.logger.info("string operator, setex complete")
self.logger.info("send redis command: \(command) complete")
continuation.resume(returning: r)
}
else if case .failure(let error) = completion {
Expand All @@ -124,9 +120,8 @@ class RediStackClient {
}
}

/**
公共底层请求redis 数据方法, 不处理任何异常, 使用者需要自己行处理异常信息
*/

// 公共底层请求redis 数据方法, 不处理任何异常, 使用者需要自己行处理异常信息
func _send<R>(_ command: RedisCommand<R>) async throws -> R {
let conn = try await getConn()
return try await _send(conn, command)
Expand Down Expand Up @@ -320,11 +315,9 @@ class RediStackClient {
self.logger.info("redis client- connection pool close")

self.closeSSH()

// self.keepaliveTask?.cancel()
}

deinit {
func shutdown() {
do {
logger.info("gracefully shutdown event loop group start...")
try self.eventLoopGroup.syncShutdownGracefully()
Expand Down
4 changes: 2 additions & 2 deletions redis-pro/Common/RedisClient/RedisClientList.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ extension RediStackClient {
throw BizError("list value: \(value), index: \(index) have changed, please check!")
}

try await _lset(key, index: index, value: Constants.LIST_VALUE_DELETE_MARK)
try await _lset(key, index: index, value: Const.LIST_VALUE_DELETE_MARK)

return try await _lrem(key,value: Constants.LIST_VALUE_DELETE_MARK)
return try await _lrem(key,value: Const.LIST_VALUE_DELETE_MARK)
} catch {
handleError(error)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,23 @@ extension RediStackClient {

let command:RedisCommand<RESPValue?> = .get(RedisKey(key))
let r = await send(command)
return r??.description ?? Cons.EMPTY_STRING
return r??.description ?? Const.EMPTY_STRING
}

func getRange(_ key:String, start:Int = 0, end:Int) async -> String {
logger.info("get value range, key:\(key), start:\(start), end:\(end)")

let command:RedisCommand<String> = .getRange(key, start: start, end: end)
let r = await send(command)
return r?.description ?? Const.EMPTY_STRING
}

func strLen(_ key:String) async -> Int {
logger.info("get value length, key:\(key)")

let command:RedisCommand<Int> = .strln(RedisKey(key))
let r = await send(command)
return r ?? 0
}

func del(_ key:String) async -> Int {
Expand Down
Loading

0 comments on commit b61e135

Please sign in to comment.