Feature on local cache or service?

496
2
04-28-2021 11:39 AM
MarkHolm
New Contributor II

Is there any indicator that a feature was returned from the local cache and not from the service? We have a backend process that essentially deletes and re-adds the feature, causing the attributes to be identical except for the objectid. From the runtime, the original feature was loaded and cached. And when the map is moved, the new feature is found in the extent. Then when an identify or a query is performed, both features are returned causing some issues. Is there any indication of that the feature is only locally?

 

The only fix for this that I see is to either call loadOrRefresh on the features, thereby deleting the local only one or setting the refresh interval so that the local feature is removed periodically.

0 Kudos
2 Replies
JamesBallard1
Esri Regular Contributor

Hi @MarkHolm ,

No, there is no way to know if a given feature is cached vs from the service. It would be difficult to have confidence in that anyway, since features displayed on the map could fall out of sync with the service at any time.

I assume you're working with a ServiceFeatureTable, so I would recommend you look into the different feature request modes available.

https://developers.arcgis.com/qt/qml/api-reference/enums-featurerequestmode.html 

In your situation if it's critical to always have the latest data, Enums.FeatureRequestModeOnInteractionNoCache might be the best option since it will always request the latest features from the service. It does have performance implications since it needs to query the service constantly. If you view the class documentation for ServiceFeatureTable there is more information about how these options work.

Also, you may be able to use populateFromService with clearCache=true to refresh all features in conjunction with Enums.FeatureRequestModeOnInteractionCache to get better performance overall.

https://developers.arcgis.com/qt/qml/api-reference/qml-esri-arcgisruntime-servicefeaturetable.html#p...

 

Nicholas-Furness
Esri Regular Contributor

Just to add to what James said, we did add some logic at 100.11 to improve the scenario you're seeing.

In short, at 100.11 you shouldn't see this any more, even with default feature request mode of OnInteractionCache. The only exception might be if the feature is in a loaded state (this typically happens if you want to get the full information on all of a feature's attributes, and not just those attributes needed for symbology and labeling - you would have called load() on the feature, or loadAndRefresh() on the ServiceFeatureTable). I will have to double-check to see what the behavior is if a cached feature that no longer exists in the service has been explicitly loaded.

Before 100.11, what you can do is take the two features (or more) that you get back from the identify, and call loadOrRefresh() on the ServiceFeatureTable to which they belong. Any feature that was in the local cache, but that is no longer in the service's data, will have the OBJECTID cleared. It's an extra round trip to the service, but should be fairly quick unless your features have very large text fields on them.

At 100.11, this is kind of built in to the Identify. Before handing you back the results of Identify, Runtime will now recognize features that no longer exist at the service and both strip them out of the Identify response AND remove them from the local cache.

Let us know if that helps.