6

I'd like to make an ISV App / Managed package that uses the Platform Org Cache.

The clearest directions on how to do this are described in this trailhead. However, when writing my code, I am unclear what to specify for the namespace and partition when using Cache.Org.put() and Cache.Org.get().

  1. Do I get to define the namespace as part of my managed package's config (aka package components)? If yes, lets call my namespace sfdcSe

  2. Do I get to define the partition name as part of my managed package's config (aka package components)? If yes, lets call my partition coolIsvPartition

  3. When I create a cache partition in my dev org, I can not set the Namespace Prefix to sfdcSe - it is hard coded to local. How do I test my code in my dev org? I think the correct way to write it is Cache.Org.put('sfdcSe.coolIsvPartition.myKey', 'value'); HOWEVER I can't define sfdcSe namespace in Setup > Platform Cache Partition. My hope is I can just write Cache.Org.put('local.coolIsvPartition.myKey', 'value'); and it will work both in my org OR if installed into another.

Thanks in advance, I'm new to SFDC development so sorry if some of the terminology is wrong.

UPDATE: For clarification, lets keep the scope of this question to 1st Generation Packaging. A complete answer that covers 1GP and 2GP would be nice, but is not required to solve this problem (I don't think).

1 Answer 1

3

What I found for now is that

  1. Platform Cache is enabled in Dev orgs but the size of partitions is 0Mb so we can't test anything.
  2. I deployed a managed package to an org, but when trying to put using Cache.Org.put('someKey', ...); I got the message Failed Cache.Org.put() for key 'someKey': Cross-namespace PUT not supported. So apparently we had to bundle a partition with the package.
  3. However it's officially not supported to create a partition in the dev org and bundle it with the managed package. See https://help.salesforce.com/articleView?id=packaging_packageable_components.htm&type=5. Nonetheless, cache partitions are still selectable when packaging components. Note that when you select the default partition, you will get the error Cannot package default partition, but any other partition works.
  4. The way you want to refer to your partition is namespace.partition.someKey, which makes sense because you cannot bundle a default partition, so you'll have to specify the namespace and partition explicitly.
  5. Then in the subscriber org, go to the setup and assign some capacity to your packaged partition.
  6. Finally, a call to Cache.Org.put('namespace.partition.someKey', ...); works!

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .