blob: 7be84801736b7aec0a0838b5e1109bb7d4f9e97d [file] [log] [blame]
<!doctype html>
<html lang="zh-CN" dir="ltr" class="docs-wrapper docs-doc-page docs-version-1.3.2 plugin-docs plugin-id-default docs-doc-id-architecture/feature/public-enhancement-services/context-service/context-service-cache">
<head>
<meta charset="UTF-8">
<meta name="generator" content="Docusaurus v2.2.0">
<title data-rh="true">CS Cache 架构 | Apache Linkis</title><meta data-rh="true" name="viewport" content="width=device-width,initial-scale=1"><meta data-rh="true" name="twitter:card" content="summary_large_image"><meta data-rh="true" property="og:url" content="https://linkis.apache.org/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/context-service/context-service-cache"><meta data-rh="true" name="docusaurus_locale" content="zh-CN"><meta data-rh="true" name="docsearch:language" content="zh-CN"><meta data-rh="true" name="docusaurus_version" content="1.3.2"><meta data-rh="true" name="docusaurus_tag" content="docs-default-1.3.2"><meta data-rh="true" name="docsearch:version" content="1.3.2"><meta data-rh="true" name="docsearch:docusaurus_tag" content="docs-default-1.3.2"><meta data-rh="true" property="og:title" content="CS Cache 架构 | Apache Linkis"><meta data-rh="true" name="description" content="CSCache架构"><meta data-rh="true" property="og:description" content="CSCache架构"><link data-rh="true" rel="icon" href="/zh-CN/img/favicon.ico"><link data-rh="true" rel="canonical" href="https://linkis.apache.org/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/context-service/context-service-cache"><link data-rh="true" rel="alternate" href="https://linkis.apache.org/docs/1.3.2/architecture/feature/public-enhancement-services/context-service/context-service-cache" hreflang="en"><link data-rh="true" rel="alternate" href="https://linkis.apache.org/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/context-service/context-service-cache" hreflang="zh-CN"><link data-rh="true" rel="alternate" href="https://linkis.apache.org/docs/1.3.2/architecture/feature/public-enhancement-services/context-service/context-service-cache" hreflang="x-default"><link data-rh="true" rel="preconnect" href="https://AE29KQB3IA-dsn.algolia.net" crossorigin="anonymous"><link rel="alternate" type="application/rss+xml" href="/zh-CN/blog/rss.xml" title="Apache Linkis RSS Feed">
<link rel="alternate" type="application/atom+xml" href="/zh-CN/blog/atom.xml" title="Apache Linkis Atom Feed">
<link rel="alternate" type="application/json" href="/zh-CN/blog/feed.json" title="Apache Linkis JSON Feed">
<link rel="search" type="application/opensearchdescription+xml" title="Apache Linkis" href="/zh-CN/opensearch.xml"><link rel="stylesheet" href="/zh-CN/assets/css/styles.fa1466da.css">
<link rel="preload" href="/zh-CN/assets/js/runtime~main.ba93f25d.js" as="script">
<link rel="preload" href="/zh-CN/assets/js/main.b3f6618d.js" as="script">
</head>
<body class="navigation-with-keyboard">
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
<div role="region" aria-label="Skip to main content"><a class="skipToContent_fXgn" href="#docusaurus_skipToContent_fallback">Skip to main content</a></div><nav class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Toggle navigation bar" aria-expanded="false" class="navbar__toggle clean-btn" type="button"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/zh-CN/"><div class="navbar__logo"><img src="/zh-CN/img/logo.png" alt="Apache Linkis Logo" class="themedImage_ToTc themedImage--light_HNdA"><img src="/zh-CN/img/logo.png" alt="Apache Linkis Logo" class="themedImage_ToTc themedImage--dark_i4oU"></div><b class="navbar__title text--truncate">Apache Linkis</b></a><a class="navbar__item navbar__link" href="/zh-CN/download/main">下载</a><a class="navbar__item navbar__link" href="/zh-CN/community/how-to-subscribe">社区</a><a class="navbar__item navbar__link" href="/zh-CN/blog">博客</a><a class="navbar__item navbar__link" href="/zh-CN/team">团队</a><a class="navbar__item navbar__link" href="/zh-CN/user">用户</a><a href="https://docs.qq.com/doc/DUkdTTGhVSlZ0VXVt" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link">FAQ</a><div class="navbar__item dropdown dropdown--hoverable"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">Apache</a><ul class="dropdown__menu"><li><a href="https://www.apache.org/" target="_blank" rel="noopener noreferrer" class="dropdown__link">基金会</a></li><li><a href="https://www.apache.org/licenses/" target="_blank" rel="noopener noreferrer" class="dropdown__link">证书</a></li><li><a href="https://www.apache.org/events/current-event" target="_blank" rel="noopener noreferrer" class="dropdown__link">事件</a></li><li><a href="https://www.apache.org/security/" target="_blank" rel="noopener noreferrer" class="dropdown__link">安全</a></li><li><a href="https://www.apache.org/foundation/sponsorship.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">赞助</a></li><li><a href="https://privacy.apache.org/policies/privacy-policy-public.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">Privacy</a></li><li><a href="https://www.apache.org/foundation/thanks.html" target="_blank" rel="noopener noreferrer" class="dropdown__link">致谢</a></li></ul></div></div><div class="navbar__items navbar__items--right"><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link">文档</a><ul class="dropdown__menu"><li><a class="dropdown__link" href="/zh-CN/docs/latest/about/introduction">1.5.0</a></li><li><a class="dropdown__link" href="/zh-CN/docs/1.4.0/about/introduction">1.4.0</a></li><li><a class="dropdown__link" href="/zh-CN/docs/1.3.2/about/introduction">1.3.2</a></li><li><a class="dropdown__link" href="/zh-CN/docs/1.6.0/about/introduction">Next(1.6.0)</a></li><li><a class="dropdown__link" href="/zh-CN/versions">All Version</a></li></ul></div><a href="https://github.com/apache/linkis" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link header-github-link" aria-label="GitHub"></a><div class="navbar__item dropdown dropdown--hoverable dropdown--right"><a href="#" aria-haspopup="true" aria-expanded="false" role="button" class="navbar__link"><svg viewBox="0 0 24 24" width="20" height="20" aria-hidden="true" class="iconLanguage_nlXk"><path fill="currentColor" d="M12.87 15.07l-2.54-2.51.03-.03c1.74-1.94 2.98-4.17 3.71-6.53H17V4h-7V2H8v2H1v1.99h11.17C11.5 7.92 10.44 9.75 9 11.35 8.07 10.32 7.3 9.19 6.69 8h-2c.73 1.63 1.73 3.17 2.98 4.56l-5.09 5.02L4 19l5-5 3.11 3.11.76-2.04zM18.5 10h-2L12 22h2l1.12-3h4.75L21 22h2l-4.5-12zm-2.62 7l1.62-4.33L19.12 17h-3.24z"></path></svg>简体中文</a><ul class="dropdown__menu"><li><a href="/docs/1.3.2/architecture/feature/public-enhancement-services/context-service/context-service-cache" target="_self" rel="noopener noreferrer" class="dropdown__link" lang="en">English</a></li><li><a href="/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/context-service/context-service-cache" target="_self" rel="noopener noreferrer" class="dropdown__link dropdown__link--active" lang="zh-CN">简体中文</a></li></ul></div><div class="searchBox_ZlJk"><button type="button" class="DocSearch DocSearch-Button" aria-label="搜索"><span class="DocSearch-Button-Container"><svg width="20" height="20" class="DocSearch-Search-Icon" viewBox="0 0 20 20"><path d="M14.386 14.386l4.0877 4.0877-4.0877-4.0877c-2.9418 2.9419-7.7115 2.9419-10.6533 0-2.9419-2.9418-2.9419-7.7115 0-10.6533 2.9418-2.9419 7.7115-2.9419 10.6533 0 2.9419 2.9418 2.9419 7.7115 0 10.6533z" stroke="currentColor" fill="none" fill-rule="evenodd" stroke-linecap="round" stroke-linejoin="round"></path></svg><span class="DocSearch-Button-Placeholder">搜索</span></span><span class="DocSearch-Button-Keys"></span></button></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div></nav><div id="docusaurus_skipToContent_fallback" class="main-wrapper mainWrapper_z2l0 docsWrapper_BCFX"><button aria-label="回到顶部" class="clean-btn theme-back-to-top-button backToTopButton_sjWU" type="button"></button><div class="docPage__5DB"><aside class="theme-doc-sidebar-container docSidebarContainer_b6E3"><div class="sidebar_njMd"><nav class="menu thin-scrollbar menu_SIkG"><ul class="theme-doc-sidebar-menu menu__list"><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh-CN/docs/1.3.2/about/introduction">关于 Linkis</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh-CN/docs/1.3.2/feature/overview">版本特性</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh-CN/docs/1.3.2/quick/live-demo">快速体验</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh-CN/docs/1.3.2/deployment/deploy-quick">部署指南</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh-CN/docs/1.3.2/user-guide/how-to-use">使用指南</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh-CN/docs/1.3.2/engine-usage/overview">引擎使用</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh-CN/docs/1.3.2/auth/ldap">安全认证</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh-CN/docs/1.3.2/api/overview">API</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" aria-expanded="true" href="/zh-CN/docs/1.3.2/architecture/overview">架构设计</a></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.3.2/architecture/overview">总览</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-2 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.3.2/architecture/task-flow">任务流转流程介绍</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" tabindex="0" href="/zh-CN/docs/1.3.2/architecture/service-architecture/overview">微服务架构</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-2 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" aria-expanded="true" tabindex="0" href="/zh-CN/docs/1.3.2/architecture/feature/commons/variable">关键特性架构</a></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-3 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" tabindex="0" href="/zh-CN/docs/1.3.2/architecture/feature/commons/variable">公共依赖模块</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-3 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" tabindex="0" href="/zh-CN/docs/1.3.2/architecture/feature/computation-governance-services/overview">计算治理模块</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-3 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret menu__link--active" aria-expanded="true" tabindex="0" href="/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/overview">公共增强模块</a></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/overview">总览</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/public-service">公共服务架构</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-4 menu__list-item"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--active" aria-expanded="true" tabindex="0" href="/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/context-service/">上下文服务</a><button aria-label="打开/收起侧边栏菜单「上下文服务」" type="button" class="clean-btn menu__caret"></button></div><ul style="display:block;overflow:visible;height:auto" class="menu__list"><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-5 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/context-service/overview">总览</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-5 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/context-service/context-service-client">CS Client</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-5 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/context-service/context-service-highavailable">CS HA 架构设计</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-5 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/context-service/context-service-listener">CS Listener 架构</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-5 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/context-service/context-service-persistence">CS Persistence 架构</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-5 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/context-service/context-service-search">CS Search 架构</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-5 menu__list-item"><a class="menu__link menu__link--active" aria-current="page" tabindex="0" href="/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/context-service/context-service-cache">CS Cache 架构</a></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-5 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/context-service/content-service-cleanup">CS 清理接口特性</a></li></ul></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/metadata-manager">元数据管理服务架构</a></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-4 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" tabindex="0" href="/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/bml/overview">BML</a></div></li><li class="theme-doc-sidebar-item-link theme-doc-sidebar-item-link-level-4 menu__list-item"><a class="menu__link" tabindex="0" href="/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/datasource-manager">数据源管理服务架构</a></li></ul></li></ul></li></ul></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh-CN/docs/1.3.2/development/directory-structure">开发指南</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh-CN/docs/1.3.2/tuning-and-troubleshooting/overview">调优排障</a></div></li><li class="theme-doc-sidebar-item-category theme-doc-sidebar-item-category-level-1 menu__list-item menu__list-item--collapsed"><div class="menu__list-item-collapsible"><a class="menu__link menu__link--sublist menu__link--sublist-caret" aria-expanded="false" href="/zh-CN/docs/1.3.2/upgrade/upgrade-from-0.X-to-1.0-guide">升级指南</a></div></li></ul></nav></div></aside><main class="docMainContainer_gTbr"><div class="container padding-top--md padding-bottom--lg"><div class="row"><div class="col docItemCol_VOVn"><div class="theme-doc-version-banner alert alert--warning margin-bottom--md" role="alert"><div>This is documentation for <!-- -->Apache Linkis<!-- --> <b>1.3.2</b>, 非最新版本。</div><div class="margin-top--md">有关最新文档,请参阅最新稳定版本<b><a href="/zh-CN/docs/latest/architecture/feature/public-enhancement-services/context-service/context-service-cache">latest version</a></b> (<!-- -->1.5.0<!-- -->).</div></div><div class="docItemContainer_Djhp"><article><nav class="theme-doc-breadcrumbs breadcrumbsContainer_Z_bl" aria-label="页面路径"><ul class="breadcrumbs" itemscope="" itemtype="https://schema.org/BreadcrumbList"><li class="breadcrumbs__item"><a aria-label="主页面" class="breadcrumbs__link" href="/zh-CN/"><svg viewBox="0 0 24 24" class="breadcrumbHomeIcon_OVgt"><path d="M10 19v-5h4v5c0 .55.45 1 1 1h3c.55 0 1-.45 1-1v-7h1.7c.46 0 .68-.57.33-.87L12.67 3.6c-.38-.34-.96-.34-1.34 0l-8.36 7.53c-.34.3-.13.87.33.87H5v7c0 .55.45 1 1 1h3c.55 0 1-.45 1-1z" fill="currentColor"></path></svg></a></li><li class="breadcrumbs__item"><span class="breadcrumbs__link">架构设计</span><meta itemprop="position" content="1"></li><li class="breadcrumbs__item"><span class="breadcrumbs__link">关键特性架构</span><meta itemprop="position" content="2"></li><li class="breadcrumbs__item"><span class="breadcrumbs__link">公共增强模块</span><meta itemprop="position" content="3"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item"><a class="breadcrumbs__link" itemprop="item" href="/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/context-service/"><span itemprop="name">上下文服务</span></a><meta itemprop="position" content="4"></li><li itemscope="" itemprop="itemListElement" itemtype="https://schema.org/ListItem" class="breadcrumbs__item breadcrumbs__item--active"><span class="breadcrumbs__link" itemprop="name">CS Cache 架构</span><meta itemprop="position" content="5"></li></ul></nav><span class="theme-doc-version-badge badge badge--secondary">版本:1.3.2</span><div class="tocCollapsible_ETCw theme-doc-toc-mobile tocMobile_ITEo"><button type="button" class="clean-btn tocCollapsibleButton_TO0P">On this page</button></div><div class="theme-doc-markdown markdown"><header><h1>CS Cache 架构</h1></header><h2 class="anchor anchorWithStickyNavbar_LWe7" id="cscache架构"><strong>CSCache架构</strong><a class="hash-link" href="#cscache架构" title="Direct link to heading"></a></h2><h3 class="anchor anchorWithStickyNavbar_LWe7" id="需要解决的问题"><strong>需要解决的问题</strong><a class="hash-link" href="#需要解决的问题" title="Direct link to heading"></a></h3><h3 class="anchor anchorWithStickyNavbar_LWe7" id="11-内存结构需要解决的问题">1.1. 内存结构需要解决的问题:<a class="hash-link" href="#11-内存结构需要解决的问题" title="Direct link to heading"></a></h3><ol><li><p>支持按ContextType进行拆分:加快存储和查询性能</p></li><li><p>支持按不同的ContextID进行拆分:需要完成ContextID间元数据隔离</p></li><li><p>支持LRU:按照特定算法进行回收</p></li><li><p>支持按关键字进行检索:支持通过关键字进行索引</p></li><li><p>支持索引:支持直接通过ContextKey进行索引</p></li><li><p>支持遍历:需要支持通过按照ContextID、ContextType进行遍历</p></li></ol><h3 class="anchor anchorWithStickyNavbar_LWe7" id="12-加载与解析需要解决的问题">1.2 加载与解析需要解决的问题:<a class="hash-link" href="#12-加载与解析需要解决的问题" title="Direct link to heading"></a></h3><ol><li><p>支持将ContextValue解析成内存数据结构:需要完成对ContextKey和value解析出对应的关键字。</p></li><li><p>需要与与Persistence模块进行对接完成ContextID内容的加载与解析</p></li></ol><h3 class="anchor anchorWithStickyNavbar_LWe7" id="13-metric和清理机制需要解决的问题">1.3 Metric和清理机制需要解决的问题:<a class="hash-link" href="#13-metric和清理机制需要解决的问题" title="Direct link to heading"></a></h3><ol><li><p>当JVM内存不够时能够基于内存使用和使用频率的清理</p></li><li><p>支持统计每个ContextID的内存使用情况</p></li><li><p>支持统计每个ContextID的使用频率</p></li></ol><h2 class="anchor anchorWithStickyNavbar_LWe7" id="contextcache架构"><strong>ContextCache架构</strong><a class="hash-link" href="#contextcache架构" title="Direct link to heading"></a></h2><p>ContextCache的架构如下图展示:</p><p><img loading="lazy" src="/zh-CN/assets/images/linkis-contextservice-cache-01-f88da12027f01881d55746cb0ea160e4.png" width="594" height="461" class="img_ev3q"></p><ol><li><p>ContextService:完成对外接口的提供,包括增删改查;</p></li><li><p>Cache:完成对上下文信息的存储,通过ContextKey和ContextValue进行映射存储</p></li><li><p>Index:建立的关键字索引,存储的是上下文信息的关键字和ContextKey的映射;</p></li><li><p>Parser:完成对上下文信息的关键字解析;</p></li><li><p>LoadModule当ContextCache没有对应的ContextID信息时从持久层完成信息的加载;</p></li><li><p>AutoClear:当Jvm内存不足时完成对ContextCache进行按需清理;</p></li><li><p>Listener:用于监听ContextCache的Metric信息,如:内存占用、访问次数。</p></li></ol><h2 class="anchor anchorWithStickyNavbar_LWe7" id="contextcache存储结构设计"><strong>ContextCache存储结构设计</strong><a class="hash-link" href="#contextcache存储结构设计" title="Direct link to heading"></a></h2><p><img loading="lazy" src="/zh-CN/assets/images/linkis-contextservice-cache-02-141cbbb9fd040b22838d97aa342ceaa8.png" width="650" height="555" class="img_ev3q"></p><p>ContextCache的存储结构划分为了三层结构:</p><p><strong>ContextCach:</strong>存储了ContextID和ContextIDValue的映射关系,并能够完成ContextID按照LRU算法进行回收;</p><p><strong>ContextIDValue:</strong>拥有存储了ContextID的所有上下文信息和索引的CSKeyValueContext。并统计ContextID的内存和使用记录。</p><p><strong>CSKeyValueContext:</strong>包含了按照类型存储并支持关键词的CSInvertedIndexSet索引集,还包含了存储ContextKey和ContextValue的存储集CSKeyValueMapSet。</p><p>CSInvertedIndexSet:通过CSType进行分类存储关键词索引</p><p>CSKeyValueMapSet:通过CSType进行分类存储上下文信息</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="contextcache-uml类图设计"><strong>ContextCache UML类图设计</strong><a class="hash-link" href="#contextcache-uml类图设计" title="Direct link to heading"></a></h2><p><img loading="lazy" src="/zh-CN/assets/images/linkis-contextservice-cache-03-f43df4b6ed2844192de9058e9bc0d376.png" width="1927" height="1419" class="img_ev3q"></p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="contextcache-时序图"><strong>ContextCache 时序图</strong><a class="hash-link" href="#contextcache-时序图" title="Direct link to heading"></a></h2><p>下面的图绘制了以ContextID、KeyWord、ContextType去ContextCache中查对应的ContextKeyValue的整体流程。
<img loading="lazy" src="/zh-CN/assets/images/linkis-contextservice-cache-04-0a5c853730499dbb674bb4e172cc88d6.png" width="1417" height="635" class="img_ev3q"></p><p>说明:其中ContextIDValueGenerator会去持久层拉取ContextID的Array<!-- -->[ContextKeyValue]<!-- -->,并通过ContextKeyValueParser解析ContextKeyValue的关键字存储索引和内容。</p><p>ContextCacheService提供的其他接口流程类似,这里不再赘述。</p><h2 class="anchor anchorWithStickyNavbar_LWe7" id="keyword解析逻辑"><strong>KeyWord解析逻辑</strong><a class="hash-link" href="#keyword解析逻辑" title="Direct link to heading"></a></h2><p>ContextValue具体的实体Bean需要在对应可以作为keyword的get方法上面使用注解\@keywordMethod,比如Table的getTableName方法必须加上\@keywordMethod注解。</p><p><img loading="lazy" src="data:image/png;base64,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" width="316" height="105" class="img_ev3q"></p><p>ContextKeyValueParser在解析ContextKeyValue的时候,会去扫描传入的具体对象的所有被KeywordMethod修饰的注解并调用该get方法获得返回对象toString并会通过用户可选的规则进行解析,存入keyword集合里面。规则有分隔符,和正则表达式</p><p>注意事项:</p><ol><li><p>该注解会定义到cs的core模块</p></li><li><p>被修饰的Get方法不能带参数</p></li><li><p>Get方法的返回对象的toSting方法必须返回的是关键字</p></li></ol></div><footer class="theme-doc-footer docusaurus-mt-lg"><div class="theme-doc-footer-edit-meta-row row"><div class="col"><a href="https://github.com/apache/linkis-website/edit/dev/i18n/zh-CN/docusaurus-plugin-content-docs/version-1.3.2/architecture/feature/public-enhancement-services/context-service/context-service-cache.md" target="_blank" rel="noreferrer noopener" class="theme-edit-this-page"><svg fill="currentColor" height="20" width="20" viewBox="0 0 40 40" class="iconEdit_Z9Sw" aria-hidden="true"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>编辑</a></div><div class="col lastUpdated_vwxv"></div></div></footer></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages navigation"><a class="pagination-nav__link pagination-nav__link--prev" href="/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/context-service/context-service-search"><div class="pagination-nav__sublabel">上一篇</div><div class="pagination-nav__label">CS Search 架构</div></a><a class="pagination-nav__link pagination-nav__link--next" href="/zh-CN/docs/1.3.2/architecture/feature/public-enhancement-services/context-service/content-service-cleanup"><div class="pagination-nav__sublabel">下一篇</div><div class="pagination-nav__label">CS 清理接口特性</div></a></nav></div></div><div class="col col--3"><div class="tableOfContents_bqdL thin-scrollbar theme-doc-toc-desktop"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#cscache架构" class="table-of-contents__link toc-highlight"><strong>CSCache架构</strong></a><ul><li><a href="#需要解决的问题" class="table-of-contents__link toc-highlight"><strong>需要解决的问题</strong></a></li><li><a href="#11-内存结构需要解决的问题" class="table-of-contents__link toc-highlight">1.1. 内存结构需要解决的问题:</a></li><li><a href="#12-加载与解析需要解决的问题" class="table-of-contents__link toc-highlight">1.2 加载与解析需要解决的问题:</a></li><li><a href="#13-metric和清理机制需要解决的问题" class="table-of-contents__link toc-highlight">1.3 Metric和清理机制需要解决的问题:</a></li></ul></li><li><a href="#contextcache架构" class="table-of-contents__link toc-highlight"><strong>ContextCache架构</strong></a></li><li><a href="#contextcache存储结构设计" class="table-of-contents__link toc-highlight"><strong>ContextCache存储结构设计</strong></a></li><li><a href="#contextcache-uml类图设计" class="table-of-contents__link toc-highlight"><strong>ContextCache UML类图设计</strong></a></li><li><a href="#contextcache-时序图" class="table-of-contents__link toc-highlight"><strong>ContextCache 时序图</strong></a></li><li><a href="#keyword解析逻辑" class="table-of-contents__link toc-highlight"><strong>KeyWord解析逻辑</strong></a></li></ul></div></div></div></div></main></div></div><footer class="footer"><div class="container container-fluid"><div class="row footer__links"><div class="col footer__col"><div class="footer__title">Linkis</div><ul class="footer__items clean-list"><li class="footer__item"><a class="footer__link-item" href="/zh-CN/docs/latest/about/introduction">文档</a></li><li class="footer__item"><a class="footer__link-item" href="/zh-CN/faq/main">FAQ</a></li><li class="footer__item"><a href="https://github.com/apache/linkis/releases" target="_blank" rel="noopener noreferrer" class="footer__link-item">版本</a></li></ul></div><div class="col footer__col"><div class="footer__title">社区</div><ul class="footer__items clean-list"><li class="footer__item"><a href="https://github.com/apache/linkis" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub</a></li><li class="footer__item"><a href="https://github.com/apache/linkis/issues" target="_blank" rel="noopener noreferrer" class="footer__link-item">Issue Tracker</a></li><li class="footer__item"><a href="https://github.com/apache/linkis/pulls" target="_blank" rel="noopener noreferrer" class="footer__link-item">Pull Requests</a></li></ul></div><div class="col footer__col"><div class="footer__title">订阅邮件组</div><ul class="footer__items clean-list"><li class="footer__item"><a class="footer__link-item" href="/zh-CN/community/how-to-subscribe">如何订阅</a></li><li class="footer__item"><a href="mailto:dev-subscribe@linkis.apache.org" target="_blank" rel="noopener noreferrer" class="footer__link-item">订阅邮件</a></li><li class="footer__item"><a href="https://lists.apache.org/list.html?dev@linkis.apache.org" target="_blank" rel="noopener noreferrer" class="footer__link-item">邮件归档</a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright"><div style="text-align: left;">
<div>
<p style="font-family: Avenir-Medium;font-size: 14px;color: #999;line-height: 20px;">Apache Linkis is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.</p>
</div>
<div style="border-top: 1px solid #ccc;min-height: 60px;line-height: 20px;text-align: center;font-family: Avenir-Medium;font-size: 14px;color: #999;display: flex;align-items: center;"><span>Copyright © 2019-2020 The Apache Software Foundation. Apache Linkis, Linkis, and its feather logo are trademarks of The Apache Software Foundation.</span></div>
</div></div></div></div></footer></div>
<script src="/zh-CN/assets/js/runtime~main.ba93f25d.js"></script>
<script src="/zh-CN/assets/js/main.b3f6618d.js"></script>
</body>
</html>