Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Views Bootstrap 5.5.4 — Minor update available for module views_bootstrap (5.5.4). Release: Rightup theme 1.0.3 — Minor update available for theme vartheme_bs5_rightup (1.0.3). Release: CommentOn 1.0.6 — Minor update available for module commenton (1.0.6). Release: ChatGPT Ads 1.0.3 — Minor update available for module chatgpt_ads (1.0.3). Release: Opensolr Search 5.1.3 — Minor update available for module opensolr_search (5.1.3). Release: ServiceM8 Webform Integration 1.2.1 — Minor update available for module servicem8_webform (1.2.1). Release: PostfixAdmin 1.0.0 — Initial release available for module postfix_admin (1.0.0)! Release: ip_analyser 1.0.3 — Minor update available for module ip_analyser (1.0.3). Module Revived: Swagger-PHP OpenAPI 3 documentation generator 1.0.0 — Module swagger_php updated after 10 months of inactivity (1.0.0). Security Coverage: Microsoft Azure AI — Module ai_provider_azure now has official Drupal security advisory coverage.

This module provides a cache backend which leverages gzip compression for the
stored data.

Upon cache set the cache data will be gzipped, if the gzipped data is smaller
than the original data the compressed data will be stored in the cache bin.

This Database Backend adds two additional states to serialized column of Drupal
cores DatabaseBackend.

- SERIALIZED_COMPRESSED (2): a serialized object, compressed.
- STRING_SERIALIZED_COMPRESSED (3): a compressed string.

Benchmark

100k+ nodes, same time needed for generation as with the default database backend. Storage comparison:

bin default database backend (total size in MB) compressed cache database backend (total size in MB) reduction in % cache_data 4385,48 532,48 87,85811359 cache_dynamic_page_cache 12419,56 4486,42 63,87617597 cache_page 20641,09 5701,08 72,37994699 cache_render 7026,89 3110,8 55,73005981

Please add your findings to Benchmarks, comparison

Requirements

php functions: gzcompress, gzuncompress come with zlib extension.

Installation

download and install the module as ususal.

Swap the existing database backend with our compressed one in settings.php:

    // Default cache bin
    $settings['cache']['default'] = 'cache.backend.database_compressed_cache';
    // Specific cache bins
    $settings['cache']['bins']['data'] = 'cache.backend.database_compressed_cache';
    $settings['cache']['bins']['dynamic_page_cache'] = 'cache.backend.database_compressed_cache';
    $settings['cache']['bins']['render'] = 'cache.backend.database_compressed_cache';
    $settings['cache']['bins']['page'] = 'cache.backend.database_compressed_cache';

Advanced settings

/**
     * Compression level
     * default = 6
     * @see http://php.net/gzcompress
     */
    $settings['compressed_cache']['cache_compression_ratio'] = 1;

    /**
     * Minimum string length to add compression.
     * Seems to be completely based on gut feeling. can not find any sources googling this topic.
     */
    $settings['compressed_cache']['cache_compression_size_threshold'] = 100;
    
    /**
     * Whether garbage collection is enabled or not. Defaults to TRUE.
     */
    $settings['compressed_cache']['garbage_collection_enabled'] = TRUE;

Related issues

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Sep 2023
Latest release
3 years ago
Releases (12 mo)
0
Maintenance
Dormant

Releases

Version Type Core Release date
8.x-1.2 Stable Sep 11, 2023