diff --git a/README.markdown b/README.markdown index 016c323..ac0bce1 100644 --- a/README.markdown +++ b/README.markdown @@ -68,54 +68,54 @@ are not (atomic counter). **Explained and commented working example of file ``/config/factories.yml``** - all: - view_cache: - class: sfTaggingCache - param: - logging: true # logging is enabled ("false" to disable) - cache: - class: sfMemcacheCache # Content will be stored in Memcache - # Here you can switch to any other backend - # (see Restrictions block for more info) - param: - persistent: true - storeCacheInfo: false - host: localhost - port: 11211 - timeout: 5 - lifetime: 86400 # default value is 1 day (in seconds) - - - locker: # locks storage (could be same as - # the cache storage) - # if "locker" not setted (is "~"), it will - # be the same as cache (e.i. sfMemcacheCache) - - class: sfAPCCache # Locks will be stored in APC - # Here you can switch to any other backend sf*Cache - # (see Restrictions block for more info) - param: {} - - view_cache_manager: - class: sfViewCacheTagManager # Extended sfViewCacheManager class - #param: - # … your params here + all: + view_cache: + class: sfTaggingCache + param: + logging: true # logging is enabled ("false" to disable) + cache: + class: sfMemcacheCache # Content will be stored in Memcache + # Here you can switch to any other backend + # (see Restrictions block for more info) + param: + persistent: true + storeCacheInfo: false + host: localhost + port: 11211 + timeout: 5 + lifetime: 86400 # default value is 1 day (in seconds) + + + locker: # locks storage (could be same as + # the cache storage) + # if "locker" not setted (is "~"), it will + # be the same as cache (e.i. sfMemcacheCache) + + class: sfAPCCache # Locks will be stored in APC + # Here you can switch to any other backend sf*Cache + # (see Restrictions block for more info) + param: {} + + view_cache_manager: + class: sfViewCacheTagManager # Extended sfViewCacheManager class + #param: + # … your params here **Short working example to start caching with tags using APC (location: ``/config/factories.yml``)** - all: - view_cache: - class: sfTaggingCache - param: - logging: true - cache: { class: sfAPCCache, param: {} } - locker: ~ + all: + view_cache: + class: sfTaggingCache + param: + logging: true + cache: { class: sfAPCCache, param: {} } + locker: ~ - view_cache_manager: - class: sfViewCacheTagManager - param: - cache_key_use_vary_headers: true - cache_key_use_host_name: true + view_cache_manager: + class: sfViewCacheTagManager + param: + cache_key_use_vary_headers: true + cache_key_use_host_name: true > **Restrictions**: Backend's class should be inherited from ``sfCache`` class. Also, it should support the caching of objects and/or arrays. @@ -128,194 +128,140 @@ are not (atomic counter). Example of file ``/config/doctrine/schema.yml`` - YourModel: - tableName: your_model - actAs: - ## CONFIGURATION SHORT VERSION - ## Cachetaggable will detect your primery keys automaticaly - ## and generates uniqueKeyFormat based on PK column count - ## (e.g. '%s_%s' if table contains 2 primary keys) - Cachetaggable: ~ - - ## CONFIGURATION EXPLAINED VERSION - #Cachetaggable: - # uniqueColumn: id # you can customize unique column name (default is all table primary keys) - # versionColumn: object_version # you can customize version column name (default is "object_version") - # uniqueKeyFormat: '%s' # you can customize key format (default is "%s") - # - # # if you have more then 1 unique column, you could pass all of them - # # as array (tag name will be based on all of them) - # - # uniqueColumn: [id, is_enabled] - # uniqueKeyFormat: '%d-%02b' # the order of unique columns - # # matches the "uniqueKeyFormat" template variables order + YourModel: + tableName: your_model + actAs: + ## CONFIGURATION SHORT VERSION + ## Cachetaggable will detect your primery keys automaticaly + ## and generates uniqueKeyFormat based on PK column count + ## (e.g. '%s_%s' if table contains 2 primary keys) + Cachetaggable: ~ + + ## CONFIGURATION EXPLAINED VERSION + #Cachetaggable: + # uniqueColumn: id # you can customize unique column name (default is all table primary keys) + # versionColumn: object_version # you can customize version column name (default is "object_version") + # uniqueKeyFormat: '%s' # you can customize key format (default is "%s") + # + # # if you have more then 1 unique column, you could pass all of them + # # as array (tag name will be based on all of them) + # + # uniqueColumn: [id, is_enabled] + # uniqueKeyFormat: '%d-%02b' # the order of unique columns + # # matches the "uniqueKeyFormat" template variables order 1. Enable cache in ``settings.yml`` and add additional helpers to ``standard_helpers`` section - To setup cache, often, used a separate environment named "cache", + To setup cache, often, is used a separate environment named "cache", but in the same way you can do it in any other environments which you already have. - prod: - .settings: - cache: true - - cache: - .settings: - cache: true - - all: - .settings: - cache: false - - Add helpers to the frontend application. - - all: - .settings: - standard_helpers: - # … other helpers - - Partial # build-in Symfony helper to work with partials/components - - Cache # build-in Symfony helper to work with cache - - CacheTag # sfCacheTaggingPlugin helper to tagging features - -1. Customize ``sfCacheTaggingPlugin`` in the ``/config/app.yml`` - - Explained and commented version of ``/config/app.yml`` (project level or to each application's level ``/apps/%application_name%/config/app.yml``) - - all: - sfcachetaggingplugin: - - template_lock: "lock_%s" # name for locks (recommended to include constant %SF_ENVIRONMENT%) - template_tag: "tag_%s" # name for tags (recommended to include constant %SF_ENVIRONMENT%) - - microtime_precision: 5 # version precision - # (0 - without micro time (only seconds), version will be 10 digits length) - # (5 - with micro time part, version will be 15 digits length) - # (max precision value = 6, min = 0, only decimal numbers) - - lock_lifetime: 2 # number of seconds to keep lock, if failed to unlock after locking it (default value if not set 2) - # value should be more then zero - - tag_lifetime: 86400 # number of seconds to keep tags alive (default value if not set 86400) - # it is recommended to keep this value the same as you have declared in factories.yml at "all_view_cache_param_cache_param_lifetime" (86400) - # value should be more then zero - - log_format_extended: 0 # logs will be stored in ``log/cache_%environment_name%.log`` - # "0" print 1 char in one line - # "1" print 1 char, cache key, additional data (if available) per line - # - # Char explanation: - # "g": content cache not found - # "G": content cache is found - # "l": could not lock the content or the tag - # "L": content/tag was locked for writing - # "s": could not write new values to the cache (e.g. for lock reasons) - # "S": new values are saved to the cache - # "u": could not unlock the cache - # "U": cache was unlocked - # "t": cache tag was expired - # "T": cache tag is up-to-date - # "p": could not write new version of tag - # "P": tag version is updated - # - # Chars in lower case indicate negative operation - # Chars in upper case indicate positive operation - - #object_class_tag_name_provider: # you can customize tag name naming - # # useful for multi-environment models - # - ProjectToolkit # [class name] - # - formatObjectClassName # [static method name] - - Minified ``/config/app.yml`` content: - - all: - sfcachetaggingplugin: - template_lock: "%SF_ENVIRONMENT%_lock_%s" - template_tag: "%SF_ENVIRONMENT%_tag_%s" - microtime_precision: 5 - lock_lifetime: 2 - tag_lifetime: 86400 - log_format_extended: 0 + prod: + .settings: + cache: true + + cache: + .settings: + cache: true + + all: + .settings: + cache: false + + Add helpers to the each application: + + all: + .settings: + standard_helpers: + # … other helpers + - Partial # build-in Symfony helper to work with partials/components + - Cache # build-in Symfony helper to work with cache + - CacheTag # sfCacheTaggingPlugin helper with cache tagging features + +1. Customize ``sfCacheTaggingPlugin`` in the ``app.yml`` + + Explained and commented version of ``app.yml``: + + all: + sfcachetaggingplugin: + + template_lock: "lock_%s" # Name for locks. + template_tag: "tag_%s" # Name for tags. + + microtime_precision: 5 # Version precision. + # 0: without micro time, version length 10 digits + # 5: with micro time part, version length 15 digits + # (allowed decimal numbers in range [0, 6] + + lock_lifetime: 2 # Number of seconds to keep lock, if failed to + # unlock after locking it. + # Value should be more then zero. + + tag_lifetime: 86400 # Number of seconds to keep tags alive + # (default value if not set 86400). + # It's recommended to keep this value the same as + # you have declared in factories.yml at + # "all_view_cache_param_cache_param_lifetime" (86400). + # Value should be more then zero. + + log_format_extended: 0 # Logs will be stored in ``log/cache_%environment_name%.log`` + # 0: Print 1 char in one line. + # 1: Print 1 char + cache key + additional data + # (if available) per line. + # + # Char explanation: + # "g": content cache not found + # "G": content cache is found + # "l": could not lock the content or the tag + # "L": content/tag was locked for writing + # "s": could not write new values to the cache + # (e.g. for lock reasons) + # "S": new values are saved to the cache + # "u": could not unlock the cache + # "U": cache was unlocked + # "t": cache tag was expired + # "T": cache tag is up-to-date + # "p": could not write new version of tag + # "P": tag version is updated + # + # Chars in lower case indicate negative operation. + # Chars in upper case indicate positive operation. + + #object_class_tag_name_provider: # you can customize tag name naming + # # useful for multi-environment models + # - ProjectToolkit # [class name] + # - formatObjectClassName # [static method name] + + Minified ``app.yml`` content: + + all: + sfcachetaggingplugin: + template_lock: "%SF_ENVIRONMENT%_lock_%s" + template_tag: "%SF_ENVIRONMENT%_tag_%s" + microtime_precision: 5 + lock_lifetime: 2 + tag_lifetime: 86400 + log_format_extended: 0 ## Usage ## -There are two known ways to cache partials and components: - - 1. ### First way is to configure module-level ``cache.yml``: - - _my_partial: - enabled: true - lifetime: 600 - - _myCompdonent: - enabled: true - - And main template (e.g. ``indexSuccess.php``) will looks like: - - [php] -