New in Sugar 6.2: Enhanced SugarCache

sugarcrmdevelopers —  March 31, 2011 — 1 Comment

One area of the app that got a bit of focus during the Sugar 6.2 development cycle is the SugarCache layer. SugarCache is designed to provide a consistent API to the various third party caches available for use with PHP, such as APC, Memcache, Wincache, and Zend Cache. This allows us to easily ( and most often, transparently ) support any of those caches if they are available on your system with little to no configuration needed. We do this by having a factory interface which will detect what caching mechanism is available, and then call the correct backend to add, retrieve, or delete items from the cache.

In Sugar 6.2, we refactored this interface to provide some new abilities, namely

  • Added an Object-oriented API in addition to the existing procedural API. Here’s a quick mapping of what the existing procedural methods are and how to do the same with the OOP API.
Procedural API OOP API
sugar_cache_put($key, $value) SugarCache::instance()->$key = $value
sugar_cache_retrieve($key) SugarCache::instance()->$key
sugar_cache_clear($key) unset(SugarCache::instance()->$key)
sugar_cache_reset() SugarCache::instance()->reset()
  • Improved the existing backends for better detection of availability and more efficient use of the given backend APIs.
  • Added sugar config setting ‘external_cache_force_backend’ where you can skip the backend detection logic and instead always use the specified caching backend.
  • Added an API to Redis using the PHP Redis extension.
  • Enable developers to build their own caching backends to use with Sugar. To do this, you’ll need to implement the 4 methods that handle dealing with the external cache itself ( _setExternal(), _getExternal(), _clearExternal(), and _resetExternal() ) along with adding any needed rules for detecting your backend being available to Sugar in the useBackend() method and setting the priority for detection with the $_priority property. Below is the code used for the Redis backend which illustrates this.

These enhancements now provide a much more robust and cleaner way to integrate new and upcoming caching platforms into the product in the future.

One response to New in Sugar 6.2: Enhanced SugarCache


    I came to know more about SugarCRM Cache Directory which store uploaded files and e-mails even it contain many sub directories, hodgepodge of user data files, configuration files.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s