1. 21 Jun, 2020 1 commit
    • Nathan Harris's avatar
      Rename ELF extension `map` to `tryConverting` and make internal · c4ff3fc3
      Nathan Harris authored
      Motivation:
      
      As originally pointed out in #48, the `map` prefix alone is not enough context into what the method actually does.
      
      Since it fails the future, and isn't a mapping function, the name should reflect this.
      
      But, this method as-is currently provides little value outside of the client context, so it should not be `public`.
      
      If users provide an adequate use case for having it outside of the package, then it can be made public again.
      
      Modifications:
      
      - Rename: ELF where Value == RESPValue extension `map` to `tryConverting`
      - Change: `tryConverting` from public to internal
      
      Result:
      
      A "problematic" method should no longer be available for API users to hurt themselves with.
      c4ff3fc3
  2. 04 Jun, 2020 2 commits
    • George Barnett's avatar
      Add SETEX and PSETEX commands · e7b451c4
      George Barnett authored
      Motivation:
      
      The SETEX and PSETEX commands are missing.
      
      Modifications:
      
      - Add SETEX command
      - Add PSETEX command
      - Add integration tests
      
      Result:
      
      Users can atomically set a key with an expire
      e7b451c4
    • George Barnett's avatar
      Add SET options · ddfc7b0a
      George Barnett authored
      Motivation:
      
      SET has a range of options for setting expirations and conditionally
      setting a value.
      
      Modification:
      
      - Add another `set` function with a range of options. Options are
        modelled as `struct`s backed by private `enum`s to allow additional
        options to be added without breaking API.
      - Added tests
      
      Result:
      
      Options may be specified with `set`, and resolves #67
      ddfc7b0a
  3. 02 Jun, 2020 1 commit
    • George Barnett's avatar
      Add SETNX command · 4b06ece0
      George Barnett authored
      Motivation:
      
      The SETNX command is missing.
      
      Modifications:
      
      - Add SETNX command
      - Add integration test
      
      Result:
      
      Users can set a key only if it does not already exist
      4b06ece0
  4. 20 Mar, 2020 2 commits
    • Nathan Harris's avatar
      Reduce RESPValue initialization complexities and simplify RedisKey implementation · c1ba6710
      Nathan Harris authored
      Motivation:
      
      `RESPValue` exposes a fair amount of complexity on how to intialize a single instance with the various overloads.
      
      This aims to simplify the complexity for developers by providing a single initializer and relying on `RESPValueConvertible` to handle the complexities.
      
      In addition, the Swift complier synthesizes a lot of default conformances that `RedisKey` has manually written, which is just unnecessary code.
      
      Modifications:
      
      - Rename: `RESPValue.init(_:)` to `RESPValue.init(from:)`
      - Change: `RESPValue.init` `String?` and `FixedWidthInteger` overloads from `public` to `internal`
      - Remove: Unnecessary code for various protocol conformances for `RedisKey`
      
      Result:
      
      Developers should have a direct and guided way of making instances of `RESPValue`
      c1ba6710
    • Nathan Harris's avatar
      Refine Redis Command API · 41f9377d
      Nathan Harris authored
      Motivation:
      
      It was noticed that many of the commands are cumbersome to use with boilerplate type casting for each use that can be simplified within the library
      by doing type conversion before returning the value to an end user.
      
      Modifications:
      
      Many APIs that return a `RESPValue` now have overloads to provide a `RESPValueConvertible` type that the value will be turned into before being returned.
      
      For a few APIs that returned `RESPValue`, they did so as an Optional. Those APIs have been changed to always provide a `RESPValue` and return `.null` in cases where `nil` was returned.
      
      In addition, the `@inlinable` attribute has been removed from any non-generic command API.
      
      Result:
      
      Developers should have less code boilerplate for turning values from `RESPValue` to their desired type with many commands.
      41f9377d
  5. 20 Feb, 2020 1 commit
  6. 28 Dec, 2019 1 commit
    • Nathan Harris's avatar
      Add type-safe representation of Redis keys · ea6f4279
      Nathan Harris authored
      Motivation:
      
      Inspired by Swift by Sundell's article on type-safe identifers, the goal of this commit is to have the compiler
      assist in preventing incorrect Redis key values from being used in API calls.
      
      See https://www.swiftbysundell.com/articles/type-safe-identifiers-in-swift/ for the inspiration.
      
      Modifications:
      
      - Add new `RedisKey` struct that wraps around a single `String` value that conforms to several expected protocols
        (Hashable, Comparable, Codable, etc.)
      - Change all command APIs to require `RedisKey` rather than plain strings
      
      Result:
      
      When encountering an API requiring a RedisKey, it should be much more apparant at the use site what form a value should take.
      ea6f4279
  7. 27 Oct, 2019 2 commits
    • Nathan Harris's avatar
      Add variadic overloads for several commands · adcff650
      Nathan Harris authored
      Motivation:
      
      For ergonomics, users sometimes want to provide arguments as a variadic list rather than an array.
      
      Modifications:
      
      - Add variadic overloads for almost all methods that accept lists of homogenous types
      
      Result:
      
      Users should have more flexibility in the way arguments are passed to command methods
      adcff650
    • Nathan Harris's avatar
      Add RedisClient.get generic overload · 9e5179f3
      Nathan Harris authored
      Motivation:
      
      It is wrong to always assume that a GET operation is expecting a String response type, as users may be storing other types of data.
      
      Modifications:
      
      - Add `get` generic method with a constraint for types of `RESPValueConvertible` to convert values to the user desired type
      - Change existing `get` method to specialize the generic overload
      - Fix incorrect doc block regarding the ELF failure condition
      
      Result:
      
      Users should now be able to specialize the return type of a "GET" command
      9e5179f3
  8. 09 Jul, 2019 1 commit
  9. 04 Jul, 2019 1 commit
    • Nathan Harris's avatar
      59 -- Use `RESPValueConvertible` as Generic Constraint · fa227b0e
      Nathan Harris authored
      Motivation:
      
      Johannes continues to provide great insight, and correctly pointed out that `RESPValueConvertible` was being used as an "existential" in all cases.
      
      This can cause unexpected type-erasure and introduce unnecessary cost overhead with dynamic dispatch when in most cases we know the exact value we want for `RESPValue` to execute commands.
      
      Modifications:
      
      - Add new extensions to `Array where Element == RESPValue` for appending and adding elements into them
      - Change `RedisClient.send(command:with:)` to require `[RESPValue]` instead of `[RESPValueConvertible]` as the `with` argument type
      - Change all instances of `RESPValueConvertible` being an "existential" type for method arguments to instead be a generic constraint
      
      Result:
      
      The library should be safeguarded from a class of bugs, with the use of `send` being a bit more straight forward, with some new convenience methods for `[RESPValue]` types.
      fa227b0e
  10. 25 Jun, 2019 3 commits
  11. 06 Jun, 2019 1 commit
    • Nathan Harris's avatar
      Rename `NIORedis` to `RedisNIO` · e81f9546
      Nathan Harris authored
      Motivation:
      
      The SSWG has identified a fast approaching reality of namespace clashes in SPM within the ecosystem and has proposed a rule on names that `NIORedis` no longer complies with.
      
      Modifications:
      
      All references to `NIORedis` have been switched to `RedisNIO` as this module name is unique (at least within GitHub's public repositories).
      
      The goals for this name are as follows:
      
      1. To indicate that this is a Redis client library that is built with SwiftNIO
      2. That it is a lower level library, as it directly exposes SwiftNIO as an implementation detail
          2a. The idea being that a higher level library (`Redis`) will be used, and to "go one level deeper" in the stack, you append the "deeper" `NIO` postfix
      3. It follows a naming pattern adopted by Vapor who has expressed their desire to adopt this library as their Redis implementation
      
      Result:
      
      A repository, package name, and module name that are unique across GitHub's public repositories that achives the goals outlined above.
      e81f9546
  12. 01 May, 2019 1 commit
  13. 28 Mar, 2019 1 commit
    • Nathan Harris's avatar
      Simplify `RedisCommandExecutor` and `RedisConnection` · 9f049eb4
      Nathan Harris authored
      Motivation:
      
      `RedisCommandExecutor` was a complex and "wordy" name that was not 100% clear as to how it relates to other types.
      
      `RedisConnection` also has not had a strong use case shown for it to exists as a separate protocol - using up a great name for the "out of the box" implementation.
      
      Result:
      
      `RedisClient` instead of `RedisCommandExecutor` is more clear as to what it is, in Redis terminology, a communication client.
      
      `RedisConnection` as a concrete class provides an identifiable basic block for making connections to Redis.
      
      `RedisConnection` also saw some fixes to `close()` while having some names and comment blocks tweaked for updated naming.
      9f049eb4
  14. 25 Mar, 2019 1 commit