Hi Everyone,
I hope this message finds you well, I want to begin by expressing my profound gratitude to @FranzBusch, His mentorship has been invaluable in this project thus far and ive gained an enormous amount of knowledge during this summer GSoC experience. With each iteration of our API, Franz has challenged me to consistently strive for excellence in every facet of software development. He has also guided me through the intricacies of open source software, fostering in me a deep and comprehensive understanding. I am immensely thankful for his guidance and support.
I am excited to share with you the progress we have made on the development of our native Swift Memcached client over the past month. We have been working diligently and I am pleased to report the completion of several key issues that have set a robust foundation for the project.
-
Implementation of our MemcachedRequestEncoder
and MemcachedRequest
.
- We’ve created an encoder handler capable of serializing a
MemcachedRequest
.
-
Implementation of our MemcachedResponseDecoder
and MemcachedResponse
.
- We’ve created a decoder handler that can transform a
ByteBuffer
received from the Memcached server into a MemcachedResponse
.
-
Get
Request Implementation.
- We’ve implemented a
get
request which includes response parsing to handle the values returned by the Memcahed server.
-
Set
Request Implementation.
- We’ve implemented a
set
request, allowing us to send a set
command to the Memcached server.
-
Implementation of MemcachedFlag
for Get
Commands.
- We defined and implemented our initial
MemcahedFlags
structure focusing specially on the v
flag, which is essential for retrieving values associated with a given key.
-
Implementation of our MemcachedConnection
actor that supports get
and set
operations.
- We developed a basic actor that manages the connection lifecycle and allows interactions with the Memcached server.
-
Introduced MemcachedValue
Protocol and Conformance.
- We introduced a
MemcachedValue
protocol to manage the conversion of generic types to ByteBuffer
, providing conformance for standard swift types, and the get
and set
methods in the actor were updated to use this new protocol, enchaining type safety and versatility of interactions with Memcached servers.
Now let’s take a deep dive into our actor:
Our MemcachedConnection
allows for communicate with a Memcached. This actor takes care of establishing a connection, creating a request stream and handling asynchronous execution of commands. Here's an example of how you can use MemcachedConnection
in a program.
import NIOCore
import NIOPosix
import SwiftMemcache
@main
struct Program {
static let eventLoopGroup = MultiThreadedEventLoopGroup(numberOfThreads: 1)
static func main() async throws {
// Create a new MemcachedConnection
let memcachedConnection = MemcachedConnection(host: "127.0.0.1", port: 11211, eventLoopGroup: eventLoopGroup)
try await withThrowingTaskGroup(of: Void.self) { group in
// Start the actor's run function
group.addTask { try await memcachedConnection.run() }
// Set a value for a key on the Memcached server
let setValue = "bar"
try await memcachedConnection.set("foo", value: setValue)
// Fetch the value for a key from the Memcached server
// Expected type for the value returned from Memcache is specified
let getValue: String? = try await memcachedConnection.get("foo")
print(getValue)
// Check if the get operation was successful
// If the values do not match, an error is thrown
assert(getValue == setValue, "Value retrieved from Memcache does not match the set value")
// Cancel all tasks in the task group, which also closes the connection to Memcache
group.cancelAll()
}
}
}
While these achievements mark important milestones, we are far from finished. The road ahead includes further refining our API, incorporating more Memcached commands and functionalities, along with conducting more testing to ensure reliability and performance. You can track our progress and stay updated by monitoring the listed set of issues.
I encourage everyone to continue by providing feedback and raising issues. Your support and insights plays a critical role in shaping our progress and development. We look forward to your active participation and continued involvement.
I will continue to provide regular updates here. If you have any questions or concerns, feel free to post them in this thread.
Stay tuned for more exciting updates soon!
All the best
Delkhaz