Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PORT]Surface LG CacheScope out in LG file options #3124

Merged
merged 5 commits into from
Dec 9, 2020

Conversation

Danieladu
Copy link
Contributor

Fixes #3109

Original C# PR: microsoft/botbuilder-dotnet#4982

Description

Support the following options in LG file to specify the cache scope

> !# @cacheScope= global/local/none   // by default is local

Changes

Support setting LG cache scope in LG file

> !# @cacheScope= global // global cache
> !# @cacheScope= local // local cache
> !# @cacheScope= none // none cache
> !# @cacheScope= xxx // fallback to local cache

Global cache is effective in the life cycle of an evaluation

For example:

var templates = Templates.ParseFile("xxx.lg");
var result1 = templates.Evaluate("template", null, new EvaluationOptions { CacheScope = LGCacheScope.Global});

// The second evaluation would drop all the results cached before.
var result2 = templates.Evaluate("template", null, new EvaluationOptions { CacheScope = LGCacheScope.Global});

Option name case insensitive

> !# @cacheScope= global // ok
> !# @CACHESCOPE= global // ok
> !# @cachescope= global // ok
...

Cache scope would follow the scope of the entrance LG

For example:
a.lg:

> !# @cacheScope= global
 [import](b.lg)

b.lg

> !# @cacheScope= none
# template1
- ${template2()} ${template2()}

# template2
- ${rand(1, 10000000)}

Code:

var templates = Templates.parseFile("a.lg");
var result = templates.evaluate("template1"); // the second "template2" would use the cache of the first evaluate result

@Danieladu Danieladu requested a review from a team as a code owner December 4, 2020 13:22
@Danieladu Danieladu requested review from Stevenic and tomlm December 4, 2020 13:22
@Danieladu Danieladu marked this pull request as draft December 4, 2020 13:22
@Danieladu Danieladu changed the title Surface LG CacheScope out in LG file options [PORT]Surface LG CacheScope out in LG file options Dec 4, 2020
@coveralls
Copy link

coveralls commented Dec 4, 2020

Pull Request Test Coverage Report for Build 411426822

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 18 unchanged lines in 3 files lost coverage.
  • Overall coverage decreased (-0.04%) to 84.46%

Files with Coverage Reduction New Missed Lines %
libraries/adaptive-expressions/src/triggerTrees/node.ts 2 90.51%
libraries/botbuilder-lg/src/evaluationOptions.ts 2 89.02%
libraries/botbuilder-lg/src/evaluator.ts 14 91.78%
Totals Coverage Status
Change from base Build 411425122: -0.04%
Covered Lines: 17607
Relevant Lines: 19925

💛 - Coveralls

@Danieladu Danieladu marked this pull request as ready for review December 7, 2020 08:01
@joshgummersall
Copy link
Contributor

Not sure why the ADO tests are failing, the Github ones are green though!

@joshgummersall joshgummersall merged commit 7512309 into main Dec 9, 2020
@joshgummersall joshgummersall deleted the hond/cacheScope branch December 9, 2020 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

port: Surface LG CacheScope out in LG file options (#4982)
3 participants