jovotech / jovo-framework

🔈 The React for Voice and Chat: Build Apps for Alexa, Messenger, Instagram, the Web, and more
https://www.jovo.tech
Apache License 2.0
1.68k stars 309 forks source link

:sparkles: Add Redis Db #1559

Closed rmtuckerphx closed 1 year ago

rmtuckerphx commented 1 year ago

Proposed Changes

Add Database integration for Redis including entry splitting and TTL. Users of the plugin have the ability to encrypt Redis values without that code being part of the plugin.

Types of Changes

Checklist

rmtuckerphx commented 1 year ago

@jankoenig @aswetlow How do we solve this build error?

/node_modules/@redis/client/dist/lib/client/socket.d.ts(39,5): error TS18028: Private identifiers are only available when targeting ECMAScript 2015 and higher.

rmtuckerphx commented 1 year ago

Will removing tsconfig.build.esm5.json from db-redis solve this? What is the impact?

aswetlow commented 1 year ago

Could you add "skipLibCheck": true to tsconfig.build.esm5.json? This should solve this issue.

aswetlow commented 1 year ago

What is the latency for connect() and disconnect()?

rmtuckerphx commented 1 year ago

@aswetlow Here are some timings for Redis connect and disconnect:

getDbItem - Redis connect: 247.458ms getDbItem - Redis disconnect: 5.134ms saveData - Redis connect: 160.305ms saveData - Redis disconnect: 1.051ms

getDbItem - Redis connect: 238.067ms getDbItem - Redis disconnect: 0.911ms saveData - Redis connect: 143.946ms saveData - Redis disconnect: 0.931ms

aswetlow commented 1 year ago

Would it make sense to keep the connection alive after getDbItem and reuse it in saveData? At least for the time of the request. You could store the client in jovo. This would save ~150ms in latency.

We could improve it, even more, by using connection pools. This is something that could be done in the future.

rmtuckerphx commented 1 year ago

@aswetlow I vote to optimize in the future. This is something that I need immediately.

jankoenig commented 1 year ago

Thank you @rmtuckerphx 🎉