vapor / redis

Vapor provider for RediStack
MIT License
458 stars 57 forks source link

Change semantics of Redis sessions with key and ID generation #176

Closed Mordil closed 3 years ago

Mordil commented 3 years ago

This addresses some semantic issues with the original implementation of SessionDriver for Redis in #175.

Two important changes were made to RedisSessionsDelegate:

  1. makeNewID does not prefix the ID with vrs- anymore
  2. A new makeKey(for:) optional method has been added to the protocol to convert an ID to a RediStack.RedisKey to customize how the id is represented as a key.
    • The default implementation adds the vrs- prefix.

In addition, the protocol has seen two quality of life (breaking) changes to the required protocol methods:

  1. Their argument labels have been updated to read a bit nicer at call sites, and the RedisKey is now passed instead of a SessionID
    • redis(_:storeData:forID:) -> redis(_:store:with:)
    • redis(_:fetchDataForID:) -> redis(_:fetchDataFor:)
  2. They have been marked @inlinable in the protocol definition. To take advantage of potential inlining, make sure you also mark your conformances with @inlinable.
tanner0101 commented 3 years ago

These changes are now available in 4.0.0-rc.2