All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
This is a major version update with breaking API changes. Please see MIGRATION.md for detailed migration instructions.
NewRediStore(size, network, address, username, password, keyPairs)- Replaced byNewStore()withWithAddress()optionNewRediStoreWithDB(size, network, address, username, password, db, keyPairs)- Replaced byNewStore()withWithAddress()andWithDB()optionsNewRediStoreWithPool(pool, keyPairs)- Replaced byNewStore()withWithPool()optionNewRediStoreWithURL(size, url, keyPairs)- Replaced byNewStore()withWithURL()option
-
NewStore(keyPairs [][]byte, opts...)- New unified initialization function using Option Pattern// Single key store, err := NewStore( [][]byte{[]byte("secret-key")}, WithAddress("tcp", ":6379"), WithDB("1"), WithMaxLength(8192), ) // Multiple keys for key rotation store, err := NewStore( [][]byte{ []byte("new-auth-key"), []byte("new-encrypt-key"), []byte("old-auth-key"), // For decoding existing sessions []byte("old-encrypt-key"), }, WithAddress("tcp", ":6379"), )
- Key pairs parameter changed from
[]byteto[][]byte- Enables proper support for encryption key rotation - Keys are provided as byte slice pairs (authentication key, encryption key)
- First key pair is used for encoding new sessions
- All key pairs are tried for decoding, allowing seamless key rotation without invalidating existing sessions
-
Keys(keys ...[]byte)- Convenience function to create key pairs from byte slicesstore, err := NewStore(Keys([]byte("key")), WithAddress("tcp", ":6379"))
-
KeysFromStrings(keys ...string)- Most convenient way to create key pairs from stringsstore, err := NewStore(KeysFromStrings("secret-key"), WithAddress("tcp", ":6379"))
These helpers simplify the creation of key pairs, eliminating the need to write [][]byte{[]byte(...)} every time.
WithPool(pool)- Use custom Redis connection poolWithAddress(network, address)- Connect using network protocol and addressWithURL(url)- Connect using Redis URL
WithAuth(username, password)- Set username and password for Redis authenticationWithPassword(password)- Set password only (convenience function)
WithDB(db)- Set Redis database index as string ("0"-"15")WithDBNum(dbNum)- Set Redis database index as integer (0-15)WithPoolSize(size)- Set connection pool size (default: 10)WithIdleTimeout(timeout)- Set connection idle timeout (default: 240s)
WithMaxLength(length)- Set maximum session data size (default: 4096 bytes)WithKeyPrefix(prefix)- Set Redis key prefix (default: "session_")WithDefaultMaxAge(age)- Set default TTL in seconds (default: 1200)WithSerializer(serializer)- Set session serializer (default: GobSerializer)WithSessionOptions(opts)- Set full session optionsWithPath(path)- Set cookie path (default: "/")WithMaxAge(age)- Set cookie MaxAge (default: 30 days)
redistore_options_test.go- Comprehensive test suite for option validation- Added 23+ new tests covering:
- Configuration validation
- Error handling
- Option combinations
- Default values
- Module path updated to
github.com/boj/redistore/v2for v2 versioning - Improved error messages with detailed context
- Configuration validation moved to initialization time (fail fast)
-
Code Quality
- Eliminated code duplication across initialization functions
- Better separation of concerns with internal configuration structures
- More maintainable and extensible codebase
-
API Design
- Self-documenting option names
- Compile-time validation of configuration
- Flexible option combinations
- Better default values
-
Developer Experience
- Single entry point reduces learning curve
- Options can be applied in any order
- Clear error messages for invalid configurations
- Comprehensive documentation
- Connection validation now happens during initialization (not on first use)
- Better handling of nil values in configuration
- Improved database number validation (0-15 range)
- Added
MIGRATION.md- Comprehensive migration guide from v1 to v2 - Added
CHANGELOG.md- Version history and change tracking - Updated all code examples to use new API
- Improved inline documentation with examples
- Added
Optionfunction type for configuration - Added
storeConfigstruct for internal configuration management - Added
addressConfigstruct for network address configuration - Implemented
defaultConfig()for sensible defaults - Implemented
validate()for configuration validation - Implemented
buildPool()for pool creation from configuration
- Go Version: Requires Go 1.23+
- Dependencies: No changes to external dependencies
github.com/gomodule/redigo v1.9.3git.832008.xyz/gorilla/securecookie v1.1.2git.832008.xyz/gorilla/sessions v1.4.0
For changes prior to v2.0.0, please refer to the git history.
The v1 API included four initialization functions:
NewRediStore()- Basic initializationNewRediStoreWithDB()- With database selectionNewRediStoreWithPool()- With custom poolNewRediStoreWithURL()- With Redis URL
These have been replaced by the unified NewStore() function with options in v2.
See MIGRATION.md for step-by-step instructions on upgrading from v1 to v2.
- Issues: https://github.com/boj/redistore/issues
- Discussions: https://github.com/boj/redistore/discussions
- Documentation: https://pkg.go.dev/github.com/boj/redistore/v2