# Okta Java SDK Client cache refresh

**URL:** <https://devforum.okta.com/t/okta-java-sdk-client-cache-refresh/13499>\
**Category:** Questions\
**Created:** [March 25, 2021, 9:43am UTC](https://devforum.okta.com/t/okta-java-sdk-client-cache-refresh/13499 "2021-03-25T09:43:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mateuszr](https://avatars.discourse-cdn.com/v4/letter/m/7feea3/32.png) [@mateuszr](https://devforum.okta.com/u/mateuszr)\
**Post date:** [March 25, 2021, 9:43am UTC](https://devforum.okta.com/t/okta-java-sdk-client-cache-refresh/13499/1 "2021-03-25T09:43:09Z")

</div>

Hello,

I am trying to use Client from java sdk for Okta to update some user attributes. I am using `Clients.builder()` with proper url, clientId, apiKey and scopes. Client is properly communicating with Okta server, reading and setting values from profile attributes.

The problem appears when in meantime, the profile attribute is changed in Okta admin panel. The instance of the client does not see that changes. Even after searching for user again using:

`client.getUser(userId)`

does not help. The values of attributes that I am getting with `user.Profile.getString("attributeName")` are from before the change in the panel. I am guessing that this is somehow cached.

The only solution that I found for it is to create a new instance of client. Is there any way to avoid this and refresh the client, cache or the DataStore or something like that?

Versions:  
_com.okta.sdk:okta-sdk-api:3.0.3_  
_com.okta.sdk:okta-sdk-impl:3.0.0_  
_com.okta.sdk:okta-sdk-httpclient:3.0.3_

Thanks in advance!

Br,  
Mateusz

---

<div class="post-metadata">

**Author:** ![Lijia](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/lijia/32/2295_2.png) [@Lijia](https://devforum.okta.com/u/Lijia)\
**Post date:** [March 25, 2021, 7:11pm UTC](https://devforum.okta.com/t/okta-java-sdk-client-cache-refresh/13499/2 "2021-03-25T19:11:02Z")

</div>

@mateuszr Hi, Please take a look of the discussion and solution from [here](https://github.com/okta/okta-sdk-java/issues/311#issuecomment-526256385) Not sure if this is sth you are looking for.  
When you run the test sample, you can also enable logging for `com.okta.sdk.impl.ds.cache.DefaultResourceCacheStrategy` and it will show cache hits as well.

---

<div class="post-metadata">

**Author:** ![mateuszr](https://avatars.discourse-cdn.com/v4/letter/m/7feea3/32.png) [@mateuszr](https://devforum.okta.com/u/mateuszr)\
**Post date:** [March 26, 2021, 2:14pm UTC](https://devforum.okta.com/t/okta-java-sdk-client-cache-refresh/13499/3 "2021-03-26T14:14:08Z")

</div>

@Lijia Hello, I am afraid this is not what I am looking for or I do not understand it or know how to implement it.

Current behaviour:

```
client = Clients.builder()
    .setOrgUrl(url)
    .setClientId(clientId)
    .setScopes({"okta.users.read", "okta.users.manage"})
    .setClientCredentials(new TokenClientCredentials(apiKey))
    .build();

print(client.getUser(userId).Profile.getString("attributeName")) // prints "123"

// here there is a change of the attribute in webpage admin panel for that user to "456"

print(client.getUser(userId).Profile.getString("attributeName")) // prints "123"

```

I would expect the second print to print “456”

---

<div class="post-metadata">

**Author:** ![michael\_jeanjacques](https://avatars.discourse-cdn.com/v4/letter/m/43a26b/32.png) [@michael\_jeanjacques](https://devforum.okta.com/u/michael_jeanjacques)\
**Post date:** [March 7, 2022, 5:29pm UTC](https://devforum.okta.com/t/okta-java-sdk-client-cache-refresh/13499/4 "2022-03-07T17:29:26Z")

</div>

Any update on this? How were you able to get the updated profile value, without refreshing the client.

---

<div class="post-metadata">

**Author:** ![andrea](https://sea1.discourse-cdn.com/oktadev/user_avatar/devforum.okta.com/andrea/32/2172_2.png) [@andrea](https://devforum.okta.com/u/andrea)\
**Post date:** [February 8, 2024, 9:43pm UTC](https://devforum.okta.com/t/okta-java-sdk-client-cache-refresh/13499/5 "2024-02-08T21:43:13Z")

</div>

Closed on February 8, 2024, 9:43pm UTC


