Skip to content

Conversation

dkz2
Copy link
Contributor

@dkz2 dkz2 commented Aug 6, 2023

This PR addresses the need to enhance our Memcache functionality with add and replace operation support. These operations enable modifying key-value pairs by providing a more granular level of control over how data is stored. This PR closes #25.

Motivation:
To improve our interactions with memcached servers in a more dynamic and versatile way. Add and Replace operations not only increase cache efficiency by minimizing network round trips for data modification but also broadens our API capabilities.

Modifications:

  • Added add and replace methods to MemcachedConnection.
  • Modified our StorageMode enum to handle add and replace state.
  • Added Unit test and integration test.

Result:
With the addition of add and replace support, our API now allows users to add and modify data in the cache directly, improving cache efficiency and expanding the versatility of our API.


// MARK: - Adding a Value

/// Adds a value to a new key in the Memcached server.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Adds a value to a new key in the Memcached server.
/// Adds a new key-value pair in the Memcached server.

}
}

func testReplaceValue() async throws {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a test where the key/value pair doesn't exist yet

@dkz2 dkz2 marked this pull request as ready for review August 6, 2023 18:32
Comment on lines +360 to +361
if "\(error)" != "keyNotFound" {
throw error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah we really need to work on better public errors so we allow users to catch this without relying on the string description of the error. Let's create an issue for this.

@FranzBusch FranzBusch merged commit 9ae24ae into swift-server:main Aug 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement Add and Replace support

2 participants