Skip to content

Cache Manager

API version

License

GitHub Repo starsGitHub ReleaseCodecov

A simple way to cache data in Salesforce Apex.

Why Cache Manager?

  • Fluent API - Call different methods to work with the cache: get, put, remove, contains, etc.
  • Custom Cache Instances - Create your own platform cache instance and add it to the Cache Manager.
  • Error Handling - Automatic key validation and fallback.

Quick Start

apex
CacheManager.ApexTransaction.put('YourKey', 'Value');
CacheManager.DefaultOrgCache.put('YourKey', 'Value');
CacheManager.DefaultSessionCache.put('YourKey', 'Value');

// eg.
CacheManager.ApexTransaction.put(
    UserInfo.getUserId(),
    [SELECT Id, Name, Country FROM User WHERE Id = :UserInfo.getUserId()]
);

User currentUser = (User) CacheManager.ApexTransaction.get(UserInfo.getUserId());

Documentation

Installation

Released under the MIT License.