Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How I can clear the cache programmatically with the API or SDK classes?

Antonio Duarte February 25, 2013

Hello,

I implemented a program that inserts into database users from an active directory through JDBC..

That is, the rows are added to CWD_USER , CWD_MEMBERSHIP and CWD_GROUPS (only sometimes) tables.

But these changes are not reflected in JIRA until the server is restarted.

How I can do other than to restart so that one user can login afterwards inserted in CWD_USERS and enter?

I guess it's because of some cache, as I can clean or refresh programmatically?

Thank you very much.

Greetings.

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 25, 2013

I've tried this with the script runner plugin - https://jamieechlin.atlassian.net/wiki/display/GRV/Built-In+Scripts#Built-InScripts-ClearJIRAorGroovyCaches

You'll notice though that it says "clear caches that can be cleared" - I don't know if that includes the crowd/CWD cache. I also stopped using it because it didn't seem reliable (although I really don't know if that was down to the cache I wanted to clear was one of the ones that would respond to the cache clear event).

Antonio Duarte March 3, 2013

Thank you very much for your answer.

But it is not what I need, because it clears the cache. My program is done in Java and would like to use any official api.

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 3, 2013

This clears all caches that respond to a ClearCacheEvent:

ComponentManager.getComponentInstanceOfType(EventPublisher.class).publish(ClearCacheEvent.INSTANCE);

But this clears all caches, you might want to just find the one that you need.

Not sure what you mean by official API, I believe .publish is @PublicApi.

William Lupton December 2, 2018

I'd like to be able to clear the Groovy cache programmatically (e.g. from within a "make" rule). I saw this post but it looks a bit complicated, so I'd like first to try creating my own ScriptRunner REST endpoint and clearing the Groovy cache from within it.

However, I don't know the Java (or Groovy) incantation to clear the Groovy cache, and I wondered whether it might be possible to see the source of (or an appropriate fragment from the source of) the ClearCaches.groovy built-in script? From the disassembled ClearCaches.class if appears that the code quoted above is used for clearing the Java caches but not the Groovy caches.

Thanks!

TAGS
AUG Leaders

Atlassian Community Events