When working with Apigee, you'll often need to store configuration data or other values that your API proxies can access. Apigee provides two primary mechanisms for this purpose: Key Value Maps (KVMs) and Property Sets. While they share some similarities, they offer some distinct features and use cases.
Let's start off with Key Value Maps (KVMs):
Next, we can compare these same features with Property Sets:
When to Choose Which
Taking this comparison into account, we can start to realise some example use cases for each.
If your API Proxy requires a preset number of configuration variables (e.g. feature switches or parameters that change the behaviour of an API), Property Sets are suitable as they are clearly presented to an API Proxy developer who can review and make decisions on the values when they are building an API Proxy. For example, you may have a property to allow for caching to be toggled -- it's cleaner and easier to change a property instead of fiddling with conditions or trying to temporarily remove policies.
On the other hand, if your API Proxy implements a Spike Arrest policy for rate limiting, you may want to store this as a KVM entry so that it can be modified without requiring a change to any proxy deployments. It's also likely that communication with an API backend requires some static credentials that can occassionally change -- managing those credentials in a KVM would be most suitable, as the values will be encrypted and can be rotated without needing a deployment. Another great use case is to have a KVM entry that can control the availability of an API in the scenario where a backend system was to go down for scheduled maintenance -- this can allow your API Proxy to generate a well-formed response without adding unnecssary load to the unavailable backend. Just make sure you have a sensible default in place (e.g. only one specific value will cause the proxy to enter maintenance mode)