platform cache (df15 session)

24
Platform Cache A new way to do things Josh Kaplan Director, Product Management [email protected] @JoshSFDC

Upload: salesforce-partners

Post on 08-Feb-2017

62 views

Category:

Technology


0 download

TRANSCRIPT

Platform CacheA new way to do things

Josh KaplanDirector, Product [email protected]@JoshSFDC

• What’s a cache?

• How can I use the cache?

• How does it work?

• How do I get some?

Agenda

Cache Primer

What is a Cache?

Computer Cache

RAM Hard Drive

Platform Cache Database

Your Computer

Our Cloud

When To Use Platform CacheExamples of where this feature can help you

Good Idea?or Bad Idea?

My Bitcoin Exchange

Simple key-value programming model

• Just like interacting with a Map<String,Object>

• put(key, value); get(key); remove(key); contains(key);

• Type casting easily handled

Atomic Transactions

• Cache puts done at end of transaction

• “local cache” during transaction

• Data put to cache only if transaction succeeds

For sharing data that can be reused across your whole orgOrg Cache

Customer ServiceMy Bitcoin Exchange

A specialized version of org cache

• Same programming model

• User session ID logically appended to cache key

• TTL always is the user’s session

Eviction managed for you

• Time-To-Live (TTL)

• Least-recently used (LRU)

For retaining data throughout a user sessionSession Cache

To Make Your Application Faster

• Eliminate redundant expensive queries

• Eliminate redundant expensive calculations

• Stop overcrowding the Visualforce View State

To Make Application Development Easier

• Create structures in Apex

• Avoid the unique patterns for developing against Custom Settings

• No need to sweep for old stale data

Why Use Platform Cache?

Org Cache

• Data that is very likely to be needed again by multiple users

• Data that is expensive to re-create repeatedly

• Not data that can be retrieved by a simple SOQL query

• Data that is accessed frequently but changed infrequently

Session Cache

• Data that is very likely to be needed again across transactions throughout the session

• Data that is only needed in this particular user session

Hint: NOT ALWAYSWhen Do I Use Platform Cache?

The Gory Details

Guts of the Machine

Total Distributed

Cache

Guts of the Machine

Data put to the cache may not be there when you try to get it

• Application Server Shutdown

• Capacity Eviction

• Service Protection

Always expect to miss

• Builder Pattern

Consider what data belongs in the cache

• Shopping Cart: durable or not?

Consider what data does not belong in the cache

Platform Cache is NOT a durable storeWhere’s My Data?

“Take only what you need to survive”Platform Cache and Economics 101

Some for free

• 10MB for EE orgs

• 30MB for UE orgs

Some to buy

• 10MB increments

• Per-year subscription

ISV application-specific cache

• Restricted to a namespace

Temporary Free Trial

• How much should I buy?

To Avoid The Tragedy of the CommonsCash For Cache

Things we must protect:

• The Network

• Size of each stored value – serialized size

• Redis

• Number of keys

• Minimum partition size

Yes, Limits. Sorry.Limits?

Divide your cache space into the logical partitions that suit your needsPartitions

Service Cloud13MB

Shared Menus7MB

Sales Cloud10MB

Session Cache

8MB

Org Cache

5MB

Divide your cache space into the logical partitions that suit your needsPartitions

Service Cloud13MB

Shared Menus7MB

Sales Cloud40MB

Session Cache

8MB

Org Cache

5MB

Platform Cache can make your applications faster

Use Platform Cache where it makes sense

Do not abuse Platform Cache!

Platform Cache data is not durable – expect misses and handle them

Use partitions to manage churn

Purchase more Platform Cache space to improve your application performance

What To Remember

Thank you