<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Unable to set Layer caching option programatically - ArcPro SDK 2.8 in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/unable-to-set-layer-caching-option-programatically/m-p/1097542#M7115</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I'm adding feature service to map using ArcPro SDK 2.8. I've observed that that by default 'Clear Cache when session End' option is selected for each layer. Due to this option my data is not displaying properly on map. I tried to turn layer on/off manually or zoom in/out couple if times but still issue remains same.&lt;/P&gt;&lt;P&gt;I don't want to cache any data locally so I used below code to&amp;nbsp; set&amp;nbsp; cache option but UI doesn't change and still 'Clear Cahce..' is selected.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;   var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().FirstOrDefault();
  featureLayer.SetDisplayCacheType(DisplayCacheType.None);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cache.PNG" style="width: 627px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/22821iF5160CABCF69D32A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Cache.PNG" alt="Cache.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In SDK 2.7 by default last option 'Don't cache any data locally' was selected so didn't face any issue while displaying data but in 2.8 behavior has changed.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea how to set option 'Don't cache any data locally' from add-in?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Prashant&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Sep 2021 07:51:18 GMT</pubDate>
    <dc:creator>PrashantKirpan</dc:creator>
    <dc:date>2021-09-13T07:51:18Z</dc:date>
    <item>
      <title>Unable to set Layer caching option programatically - ArcPro SDK 2.8</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/unable-to-set-layer-caching-option-programatically/m-p/1097542#M7115</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;I'm adding feature service to map using ArcPro SDK 2.8. I've observed that that by default 'Clear Cache when session End' option is selected for each layer. Due to this option my data is not displaying properly on map. I tried to turn layer on/off manually or zoom in/out couple if times but still issue remains same.&lt;/P&gt;&lt;P&gt;I don't want to cache any data locally so I used below code to&amp;nbsp; set&amp;nbsp; cache option but UI doesn't change and still 'Clear Cahce..' is selected.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;   var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().FirstOrDefault();
  featureLayer.SetDisplayCacheType(DisplayCacheType.None);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cache.PNG" style="width: 627px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/22821iF5160CABCF69D32A/image-size/large?v=v2&amp;amp;px=999" role="button" title="Cache.PNG" alt="Cache.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;In SDK 2.7 by default last option 'Don't cache any data locally' was selected so didn't face any issue while displaying data but in 2.8 behavior has changed.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any idea how to set option 'Don't cache any data locally' from add-in?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Prashant&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 07:51:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/unable-to-set-layer-caching-option-programatically/m-p/1097542#M7115</guid>
      <dc:creator>PrashantKirpan</dc:creator>
      <dc:date>2021-09-13T07:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to set Layer caching option programatically - ArcPro SDK 2.8</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/unable-to-set-layer-caching-option-programatically/m-p/1097706#M7118</link>
      <description>&lt;P&gt;You can use the following method of the Layer class to change the DisplayCache settings:&lt;/P&gt;&lt;P&gt;SetDisplayCacheType&amp;nbsp;(DisplayCacheType cacheType)&lt;/P&gt;&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/#topic11758.html" target="_blank" rel="noopener"&gt;ArcGIS Pro 2.8 API Reference Guide - Layer Class Members—ArcGIS Pro&lt;/A&gt;&lt;/P&gt;&lt;P&gt;DisplayCacheType (&lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/#topic88.html" target="_blank" rel="noopener"&gt;ArcGIS Pro 2.8 API Reference Guide - DisplayCacheType Enumeration—ArcGIS Pro&lt;/A&gt;&amp;nbsp;)&lt;/P&gt;&lt;P&gt;allows the following options:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;InSession&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;Cache is maintained in session.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;MaxAge&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;Cache expires when it reaches the set maximum age.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;None&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;No cache.&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Permanent&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;Cache is permanent.&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Sep 2021 16:58:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/unable-to-set-layer-caching-option-programatically/m-p/1097706#M7118</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2021-09-13T16:58:50Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to set Layer caching option programatically - ArcPro SDK 2.8</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/unable-to-set-layer-caching-option-programatically/m-p/1097866#M7125</link>
      <description>&lt;P&gt;Yes, I'm using same layer class to change settings but no changes in UI. Here is my code&lt;/P&gt;&lt;LI-CODE lang="c"&gt; var featureLayer = MapView.Active.Map.GetLayersAsFlattenedList().OfType&amp;lt;FeatureLayer&amp;gt;().FirstOrDefault();
  featureLayer.SetDisplayCacheType(DisplayCacheType.None);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Prashant&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 00:06:55 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/unable-to-set-layer-caching-option-programatically/m-p/1097866#M7125</guid>
      <dc:creator>PrashantKirpan</dc:creator>
      <dc:date>2021-09-14T00:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: Unable to set Layer caching option programatically - ArcPro SDK 2.8</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/unable-to-set-layer-caching-option-programatically/m-p/1097875#M7126</link>
      <description>&lt;P&gt;Prashant, looks like it is a bug. We will try and get this fixed in 2.9.&lt;/P&gt;&lt;P&gt;Meanwhile, please try the following workaround (which sets the underlying FeatureCacheType manually):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;internal class DisplayCache : Button
	{
		protected async override void OnClick()
		{
			var fl = MapView.Active.Map.GetLayersAsFlattenedList()
				.OfType&amp;lt;FeatureLayer&amp;gt;().FirstOrDefault();
			if (fl == null)
				return;
			await QueuedTask.Run(() =&amp;gt;
			{
				if (fl.GetIsFeatureServiceLayer())
				{
					var def = fl.GetDefinition() as CIMFeatureLayer;
					def.DisplayCacheType = DisplayCacheType.None;
					def.FeatureCacheType = FeatureCacheType.None;
					fl.SetDefinition(def);
				}
			});
		}
	}

	internal static class FeatureServiceLayerExtensions
	{
		public static bool GetIsFeatureServiceLayer(this FeatureLayer flayer)
		{
			if (flayer.ConnectionStatus == ConnectionStatus.Broken)
				return false;
			GeodatabaseType gdbType = GeodatabaseType.FileSystem;
			using (var dataset = flayer.GetTable())
			{
				using (var gdb = dataset.GetDatastore())
				{
					//Note shapefile will be "FileSystemDatastore"
					if (gdb is Geodatabase)
					{
						gdbType = ((Geodatabase)gdb).GetGeodatabaseType();
					}
				}
			}
			return gdbType == GeodatabaseType.Service;
		}
	}&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 14 Sep 2021 01:13:22 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/unable-to-set-layer-caching-option-programatically/m-p/1097875#M7126</guid>
      <dc:creator>CharlesMacleod</dc:creator>
      <dc:date>2021-09-14T01:13:22Z</dc:date>
    </item>
  </channel>
</rss>

