Jump to content

Wrong Alfred 5.5 cache used when using alternate keywords like `foo||bar`


Recommended Posts

When using a Script Filter, we can use `$.getenv("alfred_workflow_keyword")` to display different content depending on the keyword used. For example, using `foo||bar` as the keyword, the Script Filter then shows different results for when using `foo` or `bar` as keyword. Now, when you also use the new cache mechanic from Alfred 5.5, there appears to be a bad interaction between the two:

  1. I run the Script Filter first with `foo …` and get some results displayed.
  2. If I afterward run `bar …`, Alfred uses the results cached for `foo` instead of running the script again with `bar` as `$.getenv("alfred_workflow_keyword")`. This results in the wrong results being displayed.

 

In short, it appears that Alfred creates one cache per Script Filter, and not one cache per keyword. As a consequence, this means the caching mechanic cannot be used when also using alternate keywords.

 

Build: Alfred 5.5.2257

Link to comment
Share on other sites

  • 3 weeks later...

I'm going to move this to feature suggestions as Alfred is caching as intended, and to manage expectations, it's unlikely the caching will be environmentally aware in the foreseeable future (i.e. cache differently per keyword used).

 

On 4/23/2024 at 10:30 AM, pseudometa said:

When using a Script Filter, we can use `$.getenv("alfred_workflow_keyword")` to display different content depending on the keyword used.

 

While you _could_ do this, I generally wouldn't recommend using keywords for logic in a script, as keywords are better configurable by the end user. You have a few options:

  1. Use multiple Script Filters which bootstrap to the same script
  2. Implement some custom caching within your script

Cheers,

Andrew

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...