question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

how to clear cache result with ASYNC

See original GitHub issue

i have the following

<Async 
  autoload={false}
  multi={false} 
  value={this.state.selectValue} 
  onChange={this.updateValue} 
  valueKey="value" 
  labelKey="label" 
  loadOptions={this.getCommsmatrices} 
  onValueClick={this.gotoCommsmatrix}
  cache={false}
/>

getCommsmatrices (input, callback) {
  input = input.toLowerCase(); 
  let options = this.state.options.filter(i => {
  	return i.label.toLowerCase().includes(input) == true;
  });

  let data = {
  	options: options,
  	complete: true 
  };

  setTimeout(function() {
  	callback(null, data);
  }, ASYNC_DELAY);
}

once my results are loaded it stays cached. i want to trigger this cache clean externally. how can this be done?

i want to clear the cache in the following function. I have tried setting isLoading but it does not work.

updateCommsMatrix(service_id){
  this.setState({ isLoading: true });
  this.updateValue(null);

  if(service_id > 0){
    let self = this;
  	this.props.fetchCommsmatricesByService(service_id)
      .then( response => {
        let data = response.payload.data.body.recordset.record;
        let options = self.populateOptionsObject(data, 'id', 'filename');
        options.unshift({ value: '0', label: 'All' });
        return options;
      })
      .then( options => self.setState({options:options,isLoading: false}));
  } else {
    this.setState({ options:{ value: '0', label: 'All'},isLoading: false });
  }

  this.props.dispatch(change('SecurityExemptionsNewForm', 'service_id', service_id));
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
mforman1commented, Jan 9, 2019

@JedWatson I’m using v2, please advise on how to clear the cache on this version. Thanks!

0reactions
bladeycommented, May 28, 2020

Hello -

In an effort to sustain the react-select project going forward, we’re closing old issues.

We understand this might be inconvenient but in the best interest of supporting the broader community we have to direct our efforts towards the current major version.

If you aren’t using the latest version of react-select please consider upgrading to see if it resolves any issues you’re having.

However, if you feel this issue is still relevant and you’d like us to review it - please leave a comment and we’ll do our best to get back to you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Async cache clearing · Pullstate
A big part of working with asynchronous data is being able to control the cache. ... Clear the cache for specific arguments (fingerprint)....
Read more >
Async/Await and Caching - Stack Overflow
Here's a way to cache results of asynchronous operations that guarantees no cache misses and is thread-safe. In the accepted answer, ...
Read more >
Avoid This Mistake When Caching Asynchronous Results
Caching is hard. Caching asynchronous results is even harder. Learn how to properly cache promise results in JavaScript.
Read more >
Advanced topics on caching in Apollo Client
To reset the cache without refetching active queries, use client.clearStore() instead of client.resetStore() . Responding to cache resets. You can register ...
Read more >
The functools library — asyncstdlib 3.10.5 documentation
Async Caches ¶ ... The regular functools.lru_cache() and functools.cached_property() are not appropriate for async callables, such as an async def coroutine ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found