Skip to content

Implement Add and Replace support #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 7, 2023

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