AscendingCreations / AxumSession

Axum Session Management Libraries that use Sqlx
MIT License
148 stars 33 forks source link

Add support for table names in Redis operations #77

Closed cking closed 9 months ago

cking commented 9 months ago

This update adds support for table names in Redis and Redis cluster operations. With this improvement, users can count, load, delete and check existence of keys matching the provided table name, along with general functions. An additional Redis tools module has been introduced to support key scanning.

This change makes it easy to share a single redis database for multiple purposes, thanks to prefixes for key names. It utilizes the table_name field for that.

As a side change, the KEYS command has been replaced by SCAN to optimize using REDIS on a database with many keys. The KEYS command will block the redis server, until all keys has been fetched. The SCAN command will take a cursor approach, it will only fetch a small set of keys per call, meaning it allows working on other redis commands, instead of blocking.

From https://redis.io/commands/keys/: Warning: consider KEYS as a command that should only be used in production environments with extreme care. It may ruin performance when it is executed against large databases. This command is intended for debugging and special operations, such as changing your keyspace layout. Don't use KEYS in your regular application code. If you're looking for a way to find keys in a subset of your keyspace, consider using SCAN.

genusistimelord commented 9 months ago

I will need to add these changes to the next version since it will break redis a bit for those using the default options. I plan to fix up and redo the Cookies to remove Encryption and improve signing to help secure it more and speed it up more. This will also clean the source up dynamically too making it faster.anyways thank you.