GithubHelp home page GithubHelp logo

botbuilder-storage-redis's People

Contributors

dependabot[bot] avatar doko-demo-doa avatar mokeddes avatar naktibalda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

botbuilder-storage-redis's Issues

Read method should not return an item if it is missing in storage.

It caused me unexpected issues in the code which was using MemoryStorage before.
MemoryStorage does not return an item if it is missing in the storage.

keys.forEach((key: string) => {
  const item: string = this.memory[key];
  if (item) {
    data[key] = JSON.parse(item);
  }
});

Example in Storage interface suggests that read returns undefined too.

const items = await storage.read(['botState']);
const state = items['botState'] || {};

So I think that this code is incorrent and should be modified to return only keys that exist in storage.

stateKeys.forEach((key: string, index: number): void => {
  data[key] = JSON.parse(allKeysValuesFromRedis[index] || '{}');
});

SETEX with ttlInSeconds <1 fails with "ERR invalid expire time in setex"

Using Redis 6.0.5, creating a RedisDbStorage object with ttlInSeconds <1

Result of .write() is "ERR invalid expire time in setex". It appears that at least as of Redis 6.0.5 the SETEX 'seconds' parameter must be positive.

I believe simply reverting d01f88c will suffice to fix this.

Note also that the usage example in README.md has a comment re "// data expires in 2 hours", whereas it should either read "data expires in 2 minutes" or have the ttlInSeconds updated to 3600

Feature request: expiration time

Conversation state is temporary by its nature - when the conversation ends, that data is no longer useful, but, unless it is explicitly deleted, it stays in storage for a long time, so it wastes memory and/or disk space and can cause compliance issues.
Redis has a nice feature where it is possible to set expiration time of data items (I'm not an expert in Redis), it would really useful if abandoned data would magically disappear few hours later.

I think that the expiration time could be passed as constructor argument to RedisDbStorage and default to 0.
If expiration time is 0, then it would use set command, if expiration time is more than 0, it would use setex command with expiration time as second parameter.

Does it look like a good idea?
I can make a pull request.

TypeError: this.storage.read is not a function

Hi there,

Using the latest version available 1.0.9, I'm getting this error when the bot is trying to read/update its state. Any idea why could be causing this? Could it be the package is not compatible with recent versions of the botbuilder? I'm using botbuilder 4.8.0.

0|ms-bot  | TypeError: this.storage.read is not a function
0|ms-bot  |     at Promise.resolve.then (/var/www/ms-bot/releases/20200424210108/node_modules/botbuilder-core/lib/botState.js:63:37)
0|ms-bot  | Error: BotFrameworkAdapter.processActivity(): 500 ERROR
0|ms-bot  |  TypeError: this.storage.delete is not a function
0|ms-bot  |     at Promise.resolve.then (/var/www/ms-bot/releases/20200424210108/node_modules/botbuilder-core/lib/botState.js:141:91)
0|ms-bot  |     at process._tickCallback (internal/process/next_tick.js:68:7)
0|ms-bot  |     at BotFrameworkAdapter.<anonymous> (/var/www/ms-bot/releases/20200424210108/node_modules/botbuilder/lib/botFrameworkAdapter.js:660:27)
0|ms-bot  |     at Generator.throw (<anonymous>)
0|ms-bot  |     at rejected (/var/www/ms-bot/releases/20200424210108/node_modules/botbuilder/lib/botFrameworkAdapter.js:12:65)
0|ms-bot  |     at process._tickCallback (internal/process/next_tick.js:68:7)

I do have to say that the documentation in the readme does not match with the official sample applications: https://github.com/microsoft/BotBuilder-Samples/blob/master/samples/javascript_nodejs/45.state-management/index.js#L38

I'm passing an instance of the redisStorage directly to state objects:

const redisStateStorage = new RedisDbStorage(redisClient);
const conversationState = new ConversationState(redisStateStorage);
const userState = new UserState(redisStateStorage);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.