定制 elementareteilchen/etcachetsobjects 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

elementareteilchen/etcachetsobjects

最新稳定版本:v9.0.0

Composer 安装命令:

composer require elementareteilchen/etcachetsobjects

包简介

TypoScript API to allow caching of expensive TypoScript objects like menus

README 文档

README

Idea behind

On bigger pages you have quite often big menus with lots of pages and levels (like responsive menus or flyout menus) The rendering of these menus is quite heavy and is normally done on every rendered page. If you do not need to mark active or current pages or do this client side via JavaScript, then the menu might be identical on all / several pages. Perfect to be cached!

Currently, we use it only for menus, other TypoScript objects should work, but probably the cache invalidation needs refinement then.

HINT FOR DEBUGGING: we activate caching only if no FE user is logged in. Every BE user gets her own individual cache.

Usage example 1: cache (part of) menu, which is identical on different pages

lib.menu.sector = HMENU
lib.menu.sector {
    [...]
}
// only use caching if no fe_user is logged in, else just stay with original TS
lib.menu.sector_cached < lib.menu.sector
[loginUser('*') == false]
    lib.menu.sector_cached >
    lib.menu.sector_cached = USER
    lib.menu.sector_cached {
        userFunc = ElementareTeilchen\Etcachetsobjects\UserFunc\Cache\DatabaseBackendCacheHandler->handle
        conf < lib.menu.sector
        cacheTime = 0 // "0" means unlimited liftime, cleared via backend saving hook on page changes
        //here we can set parameter needed for creating different cache entries
        additionalUniqueCacheParameters = COA
        additionalUniqueCacheParameters {
            10 = TEXT
            10.value = 0
            10.override.data = siteLanguage:languageId

            20 = TEXT
            20.value = {$theme.pages.sectorstart_id}
        }
    }
[global]

Usage example 2: cache (part of) menu, which is identical on different pages, BUT should be different again on deeper levels

That one is used when you have a very big and deep page tree. On a certain level you don't want to flyout anymore, but show subpages only for the current page

lib.menu.sector = HMENU
lib.menu.sector {
    [...]
}
[loginUser('*') == false]
    lib.menu.sector_cached >
    lib.menu.sector_cached = USER
    lib.menu.sector_cached {
        userFunc = ElementareTeilchen\Etcachetsobjects\UserFunc\Cache\DatabaseBackendCacheHandler->handle
        conf < lib.menu.sector
        cacheTime = 0 // "0" means unlimited liftime, cleared via backend saving hook on page changes
        //here we can set parameter needed for creating different cache entries
        additionalUniqueCacheParameters = COA
        additionalUniqueCacheParameters {
            10 = TEXT
            10.value = 0
            10.override.data = GP:L

            20 = TEXT
            20.value = {$theme.pages.sectorstart_id}

            // special handling because of level 5/6
            // if on level 4 and page has subpages or if on level 5 and deeper we have individual menus
            30 = USER
            30.userFunc = ElementareTeilchen\Etcachetsobjects\UserFunc\MenuVariantCheck->levelGroupIdentifier
            30.sectorstartId = {$theme.pages.sectorstart_id}
            30.individualMenusComingAtLevel = 4
        }

        // no ContentObject like COA, TEXT needed, we just want the configuration value
        additionalTags {
            10 = sector_{$theme.pages.sectorstart_id}
            #20 =
        }
    }
[global]

Usage example 3: cache expensive lib. object which is used several times on same page

lib.pageRootlineCategoryId = CONTENT
lib.pageRootlineCategoryId {
    [...]
}

lib.pageRootlineCategoryId_cached = USER
lib.pageRootlineCategoryId_cached {
    userFunc = ElementareTeilchen\Etcachetsobjects\UserFunc\Cache\TransientBackendCacheHandler->handle
    conf < lib.pageRootlineCategoryId
}

// then just replace _lib.pageRootlineCategoryId_ with _lib.pageRootlineCategoryId_cached_ wherever you use it.

Cache Invalidation

In the Extension Manager you can define which variant of invalidation you need.

PageTS Setting

Only clear cache of configured cache tags.

Specify which cache tags should be flushed when editing pages. Configure using Page TSconfig. Use cache tags you set in your TypoScript when caching menus / libs.

Add additional cache tags in TypoScript (which can be cleared via backend saving hook)

When configuring your cached menus / libs, you can add additional cache tags. Example:

lib.menu.sector_cached {
    userFunc = ElementareTeilchen\Etcachetsobjects\UserFunc\Cache\DatabaseBackendCacheHandler->handle
    conf < lib.menu.sector

    ...

    // no ContentObject like COA, TEXT needed, we just want the configuration value
    additionalTags {
        10 = sector_{$theme.pages.sectorstart_id}
        20 = cacheTag1
        30 = cacheTag2
    }
}

Configure cache tags to be cleared

Example TSconfig setting:

tx_etcachetsobjects.clearByTags = cacheTag1, cacheTag2

Site based

Clear cache of whole site in which the edited page record resides in.

From all pages

Clear all cache when a page record is edited.

统计信息

  • 总下载量: 1.29k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-2.0
  • 更新时间: 2017-10-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固