1
0
mirror of https://github.com/gnosygnu/xowa.git synced 2024-10-27 20:34:16 +00:00

Parser: Remove Tmpl_result_cache, Bld_key, and corresponding code in Xot_invk_tkn [#793]

This commit is contained in:
gnosygnu 2020-09-04 08:20:18 -04:00
parent 316c6c6a58
commit d3896bf547
9 changed files with 2040 additions and 1940 deletions

View File

@ -58,7 +58,6 @@ public class Xop_fxt {
wiki.Html_mgr().Img_suppress_missing_src_(false); wiki.Html_mgr().Img_suppress_missing_src_(false);
wiki.Xtn_mgr().Init_by_wiki(wiki); wiki.Xtn_mgr().Init_by_wiki(wiki);
Page_ttl_(Ttl_str); Page_ttl_(Ttl_str);
Xot_invk_tkn.Cache_enabled = false;// always disable cache for tests; can cause strange behavior when running entire suite and lnki_temp test turns on;
} }
private Xofw_wiki_wkr_mock mock_wkr = new Xofw_wiki_wkr_mock(); private Xofw_wiki_wkr_mock mock_wkr = new Xofw_wiki_wkr_mock();
public Xoae_app App() {return app;} private Xoae_app app; public Xoae_app App() {return app;} private Xoae_app app;

View File

@ -1,6 +1,6 @@
/* /*
XOWA: the XOWA Offline Wiki Application XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3, XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0. or alternatively under the terms of the Apache License Version 2.0.
@ -13,14 +13,43 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.addons.bldrs.mass_parses.parses.wkrs; import gplx.*; import gplx.xowa.*; import gplx.xowa.addons.*; import gplx.xowa.addons.bldrs.*; import gplx.xowa.addons.bldrs.mass_parses.*; import gplx.xowa.addons.bldrs.mass_parses.parses.*; package gplx.xowa.addons.bldrs.mass_parses.parses.wkrs;
import gplx.dbs.*; import gplx.xowa.addons.bldrs.mass_parses.dbs.*;
import gplx.xowa.files.origs.*; import gplx.Bry_bfr;
import gplx.xowa.htmls.core.htmls.*; import gplx.xowa.htmls.core.bldrs.*; import gplx.xowa.htmls.hxtns.pages.*; import gplx.xowa.htmls.core.hzips.*; import gplx.Byte_ascii;
import gplx.xowa.wikis.pages.*; import gplx.Err_;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.logs.*; import gplx.GfoMsg;
import gplx.xowa.addons.bldrs.mass_parses.parses.mgrs.*; import gplx.xowa.addons.bldrs.mass_parses.parses.utls.*; import gplx.xowa.addons.bldrs.mass_parses.parses.*; import gplx.xowa.addons.bldrs.mass_parses.parses.pools.*; import gplx.Gfo_invk;
import gplx.xowa.addons.wikis.fulltexts.indexers.bldrs.*; import gplx.Gfo_invk_;
import gplx.Gfo_usr_dlg_;
import gplx.GfsCtx;
import gplx.List_adp;
import gplx.List_adp_;
import gplx.xowa.Xoa_ttl;
import gplx.xowa.Xoae_page;
import gplx.xowa.Xowe_wiki;
import gplx.xowa.addons.bldrs.mass_parses.dbs.Xomp_mgr_db;
import gplx.xowa.addons.bldrs.mass_parses.dbs.Xomp_stat_tbl;
import gplx.xowa.addons.bldrs.mass_parses.dbs.Xomp_wkr_db;
import gplx.xowa.addons.bldrs.mass_parses.dbs.Xomp_wkr_tbl;
import gplx.xowa.addons.bldrs.mass_parses.parses.mgrs.Xomp_parse_mgr;
import gplx.xowa.addons.bldrs.mass_parses.parses.mgrs.Xomp_parse_mgr_cfg;
import gplx.xowa.addons.bldrs.mass_parses.parses.mgrs.Xomp_prog_mgr;
import gplx.xowa.addons.bldrs.mass_parses.parses.pools.Xomp_page_itm;
import gplx.xowa.addons.bldrs.mass_parses.parses.pools.Xomp_page_pool;
import gplx.xowa.addons.bldrs.mass_parses.parses.utls.Xomp_lnki_temp_wkr;
import gplx.xowa.addons.bldrs.mass_parses.parses.utls.Xomp_ns_ord_mgr;
import gplx.xowa.addons.wikis.fulltexts.indexers.bldrs.Xofulltext_indexer_wkr;
import gplx.xowa.files.origs.Xof_orig_wkr;
import gplx.xowa.htmls.core.bldrs.Xob_hdump_bldr;
import gplx.xowa.htmls.core.htmls.Xoh_wtr_ctx;
import gplx.xowa.htmls.core.hzips.Xoh_hzip_dict_;
import gplx.xowa.htmls.hxtns.pages.Hxtn_page_mgr;
import gplx.xowa.parsers.Xop_ctx;
import gplx.xowa.parsers.Xow_parser_mgr;
import gplx.xowa.parsers.logs.Xop_log_wkr_factory;
import gplx.xowa.wikis.pages.Xopg_view_mode_;
public class Xomp_parse_wkr implements Gfo_invk { public class Xomp_parse_wkr implements Gfo_invk {
// mgr vars // mgr vars
private final Xomp_parse_mgr mgr; private final Xomp_parse_mgr mgr;
@ -163,8 +192,6 @@ public class Xomp_parse_wkr implements Gfo_invk {
// cleanup // cleanup
// ctx.App().Utl__bfr_mkr().Clear_fail_check(); // make sure all bfrs are released // ctx.App().Utl__bfr_mkr().Clear_fail_check(); // make sure all bfrs are released
if (wiki.Cache_mgr().Tmpl_result_cache().Count() > 50000)
wiki.Cache_mgr().Tmpl_result_cache().Clear();
if (done_count % cleanup_interval == 0) { if (done_count % cleanup_interval == 0) {
wiki.Cache_mgr().Free_mem__page(); wiki.Cache_mgr().Free_mem__page();
wiki.Parser_mgr().Scrib().Core_term(); wiki.Parser_mgr().Scrib().Core_term();

View File

@ -38,7 +38,6 @@ public class Xop_mediawiki_wkr {
wiki.Cache_mgr().Load_wkr_(new Xow_page_cache_wkr__embeddable(wiki, loader)); wiki.Cache_mgr().Load_wkr_(new Xow_page_cache_wkr__embeddable(wiki, loader));
} }
public void Free_memory() { public void Free_memory() {
wiki.Cache_mgr().Tmpl_result_cache().Clear();
wiki.Cache_mgr().Free_mem__page(); wiki.Cache_mgr().Free_mem__page();
wiki.Parser_mgr().Scrib().Core_term(); wiki.Parser_mgr().Scrib().Core_term();
wiki.Appe().Wiki_mgr().Wdata_mgr().Clear(); wiki.Appe().Wiki_mgr().Wdata_mgr().Clear();

View File

@ -1,6 +1,6 @@
/* /*
XOWA: the XOWA Offline Wiki Application XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3, XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0. or alternatively under the terms of the Apache License Version 2.0.
@ -13,14 +13,49 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.bldrs.cmds; import gplx.*; import gplx.xowa.*; import gplx.xowa.bldrs.*; package gplx.xowa.bldrs.cmds;
import gplx.core.envs.*;
import gplx.dbs.*; import gplx.xowa.wikis.caches.*; import gplx.xowa.addons.bldrs.files.*; import gplx.xowa.files.origs.*; import gplx.Bry_;
import gplx.xowa.bldrs.wkrs.*; import gplx.Bry_bfr;
import gplx.xowa.wikis.nss.*; import gplx.Bry_bfr_;
import gplx.xowa.wikis.data.*; import gplx.xowa.wikis.dbs.*; import gplx.xowa.wikis.data.tbls.*; import gplx.Datetime_now;
import gplx.xowa.addons.bldrs.files.utls.*; import gplx.Decimal_adp;
import gplx.xowa.parsers.*; import gplx.xowa.parsers.tmpls.*; import gplx.Decimal_adp_;
import gplx.Err_;
import gplx.GfoMsg;
import gplx.Gfo_invk;
import gplx.Gfo_invk_;
import gplx.Gfo_usr_dlg;
import gplx.GfsCtx;
import gplx.Int_;
import gplx.Io_mgr;
import gplx.Io_url;
import gplx.List_adp;
import gplx.List_adp_;
import gplx.Math_;
import gplx.String_;
import gplx.core.envs.System_;
import gplx.dbs.Db_conn;
import gplx.xowa.Xoae_app;
import gplx.xowa.Xowe_wiki;
import gplx.xowa.Xowe_wiki_;
import gplx.xowa.addons.bldrs.files.utls.Xobu_poll_mgr;
import gplx.xowa.bldrs.Xob_bldr;
import gplx.xowa.bldrs.wkrs.Xob_cmd;
import gplx.xowa.bldrs.wkrs.Xob_itm_basic_base;
import gplx.xowa.files.origs.Xof_orig_wkr_;
import gplx.xowa.parsers.Xop_ctx;
import gplx.xowa.parsers.Xop_parser;
import gplx.xowa.parsers.Xop_root_tkn;
import gplx.xowa.parsers.tmpls.Xot_defn_tmpl;
import gplx.xowa.wikis.caches.Xow_defn_cache;
import gplx.xowa.wikis.data.Xow_db_file;
import gplx.xowa.wikis.data.Xow_db_file_;
import gplx.xowa.wikis.data.Xow_db_mgr;
import gplx.xowa.wikis.data.tbls.Xowd_page_itm;
import gplx.xowa.wikis.nss.Xow_ns;
import gplx.xowa.wikis.nss.Xow_ns_;
public abstract class Xob_dump_mgr_base extends Xob_itm_basic_base implements Xob_cmd, Gfo_invk { public abstract class Xob_dump_mgr_base extends Xob_itm_basic_base implements Xob_cmd, Gfo_invk {
private Xob_dump_src_id page_src; private Xob_dump_src_id page_src;
private Xow_db_mgr db_fsys_mgr; protected Xop_parser parser; protected Xop_ctx ctx; protected Xop_root_tkn root; private Xow_db_mgr db_fsys_mgr; protected Xop_parser parser; protected Xop_ctx ctx; protected Xop_root_tkn root;
@ -151,8 +186,6 @@ public abstract class Xob_dump_mgr_base extends Xob_itm_basic_base implements Xo
if (page_src != null) // some pages have no text; ignore them else null ref; PAGE: it.d:miercuri DATE:2015-12-05 if (page_src != null) // some pages have no text; ignore them else null ref; PAGE: it.d:miercuri DATE:2015-12-05
Exec_pg_itm_hook(ns_ord, ns, page, page_src); Exec_pg_itm_hook(ns_ord, ns, page, page_src);
ctx.Wiki().Utl__bfr_mkr().Clear_fail_check(); // make sure all bfrs are released ctx.Wiki().Utl__bfr_mkr().Clear_fail_check(); // make sure all bfrs are released
if (ctx.Wiki().Cache_mgr().Tmpl_result_cache().Count() > 50000)
ctx.Wiki().Cache_mgr().Tmpl_result_cache().Clear();
++exec_count; ++exec_count;
rate_mgr.Increment(); rate_mgr.Increment();
if ((exec_count % poll_interval) == 0) if ((exec_count % poll_interval) == 0)

View File

@ -1,6 +1,6 @@
/* /*
XOWA: the XOWA Offline Wiki Application XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3, XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0. or alternatively under the terms of the Apache License Version 2.0.
@ -13,11 +13,41 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.parsers.tmpls; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; package gplx.xowa.parsers.tmpls;
import gplx.core.envs.*;
import gplx.xowa.langs.*; import gplx.xowa.langs.kwds.*; import gplx.xowa.langs.funcs.*; import gplx.Array_;
import gplx.xowa.xtns.pfuncs.*; import gplx.xowa.xtns.pfuncs.ttls.*; import gplx.Bool_;
import gplx.xowa.wikis.pages.*; import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.caches.*; import gplx.xowa.wikis.data.tbls.*; import gplx.Bry_;
import gplx.Bry_bfr;
import gplx.Bry_bfr_;
import gplx.Bry_find_;
import gplx.Byte_ascii;
import gplx.Err_;
import gplx.Gfo_usr_dlg_;
import gplx.Hash_adp_bry;
import gplx.String_;
import gplx.core.envs.Env_;
import gplx.xowa.Xoa_ttl;
import gplx.xowa.Xoae_page;
import gplx.xowa.Xowe_wiki;
import gplx.xowa.langs.Xol_lang_itm;
import gplx.xowa.langs.funcs.Xol_func_itm;
import gplx.xowa.langs.kwds.Xol_kwd_grp;
import gplx.xowa.langs.kwds.Xol_kwd_grp_;
import gplx.xowa.langs.kwds.Xol_kwd_itm;
import gplx.xowa.langs.kwds.Xol_kwd_mgr;
import gplx.xowa.parsers.Xop_ctx;
import gplx.xowa.parsers.Xop_tkn_itm;
import gplx.xowa.parsers.Xop_tkn_itm_;
import gplx.xowa.parsers.Xop_tkn_itm_base;
import gplx.xowa.wikis.caches.Xow_page_cache_itm;
import gplx.xowa.wikis.data.tbls.Xowd_page_itm;
import gplx.xowa.wikis.nss.Xow_ns;
import gplx.xowa.wikis.nss.Xow_ns_;
import gplx.xowa.wikis.nss.Xow_ns_mgr_name_itm;
import gplx.xowa.wikis.pages.Xopg_tmpl_prepend_mgr;
import gplx.xowa.xtns.pfuncs.ttls.Pfunc_rel2abs;
public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk { public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
public Xot_invk_tkn(int bgn, int end) {this.Tkn_ini_pos(false, bgn, end);} public Xot_invk_tkn(int bgn, int end) {this.Tkn_ini_pos(false, bgn, end);}
@Override public byte Tkn_tid() {return typeId;} private byte typeId = Xop_tkn_itm_.Tid_tmpl_invk; @Override public byte Tkn_tid() {return typeId;} private byte typeId = Xop_tkn_itm_.Tid_tmpl_invk;
@ -275,32 +305,14 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
Bry_bfr rslt_bfr = wiki.Utl__bfr_mkr().Get_k004(); Bry_bfr rslt_bfr = wiki.Utl__bfr_mkr().Get_k004();
try { try {
Xot_invk_tkn_.Bld_key(invk_tmpl, name_ary, rslt_bfr);
byte[] rslt_key = rslt_bfr.To_bry_and_clear();
Object o = wiki.Cache_mgr().Tmpl_result_cache().Get_by(rslt_key);
Xopg_tmpl_prepend_mgr prepend_mgr = ctx.Page().Tmpl_prepend_mgr().Bgn(bfr); Xopg_tmpl_prepend_mgr prepend_mgr = ctx.Page().Tmpl_prepend_mgr().Bgn(bfr);
if (o != null) {
byte[] rslt = (byte[])o;
prepend_mgr.End(ctx, bfr, rslt, rslt.length, Bool_.Y);
bfr.Add(rslt);
}
else {
rv = defn_tmpl.Tmpl_evaluate(Xop_ctx.New__sub(wiki, ctx, ctx.Page()), invk_tmpl, rslt_bfr); // create new ctx so __NOTOC__ only applies to template, not page; PAGE:de.w:13._Jahrhundert DATE:2017-06-17 rv = defn_tmpl.Tmpl_evaluate(Xop_ctx.New__sub(wiki, ctx, ctx.Page()), invk_tmpl, rslt_bfr); // create new ctx so __NOTOC__ only applies to template, not page; PAGE:de.w:13._Jahrhundert DATE:2017-06-17
prepend_mgr.End(ctx, bfr, rslt_bfr.Bfr(), rslt_bfr.Len(), Bool_.Y); prepend_mgr.End(ctx, bfr, rslt_bfr.Bfr(), rslt_bfr.Len(), Bool_.Y);
if (name_had_subst) { // current invk had "subst:"; parse incoming invk again to remove effects of subst; PAGE:pt.w:Argentina DATE:2014-09-24 if (name_had_subst) { // current invk had "subst:"; parse incoming invk again to remove effects of subst; PAGE:pt.w:Argentina DATE:2014-09-24
byte[] tmp_src = rslt_bfr.To_bry_and_clear(); byte[] tmp_src = rslt_bfr.To_bry_and_clear();
rslt_bfr.Add(wiki.Parser_mgr().Main().Expand_tmpl(tmp_src)); // this could be cleaner / more optimized rslt_bfr.Add(wiki.Parser_mgr().Main().Expand_tmpl(tmp_src)); // this could be cleaner / more optimized
} }
if (Cache_enabled) {
byte[] rslt_val = rslt_bfr.To_bry_and_clear();
bfr.Add(rslt_val);
Hash_adp cache = wiki.Cache_mgr().Tmpl_result_cache();
cache.Del(rslt_key);
cache.Add(rslt_key, rslt_val);
}
else
bfr.Add_bfr_and_clear(rslt_bfr); bfr.Add_bfr_and_clear(rslt_bfr);
}
trace.Trace_end(trg_bgn, bfr); trace.Trace_end(trg_bgn, bfr);
} finally {rslt_bfr.Mkr_rls();} } finally {rslt_bfr.Mkr_rls();}
break; break;
@ -431,7 +443,6 @@ public class Xot_invk_tkn extends Xop_tkn_itm_base implements Xot_invk {
return itms.length == 0 ? Bry_.Empty : itms[0].Val(); return itms.length == 0 ? Bry_.Empty : itms[0].Val();
} }
private static final Hash_adp_bry ignore_hash = Hash_adp_bry.ci_a7().Add_str_obj("Citation needed{{subst", "").Add_str_obj("Clarify{{subst", ""); // ignore SafeSubst templates private static final Hash_adp_bry ignore_hash = Hash_adp_bry.ci_a7().Add_str_obj("Citation needed{{subst", "").Add_str_obj("Clarify{{subst", ""); // ignore SafeSubst templates
public static boolean Cache_enabled = false;
} }
/* /*
NOTE_1: if (finder.Colon_pos() != -1) colon_pos = finder.Func().Name().length; NOTE_1: if (finder.Colon_pos() != -1) colon_pos = finder.Func().Name().length;

View File

@ -1,6 +1,6 @@
/* /*
XOWA: the XOWA Offline Wiki Application XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3, XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0. or alternatively under the terms of the Apache License Version 2.0.
@ -13,10 +13,23 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.parsers.tmpls; import gplx.*; import gplx.xowa.*; import gplx.xowa.parsers.*; package gplx.xowa.parsers.tmpls;
import gplx.xowa.langs.kwds.*;
import gplx.xowa.xtns.pfuncs.*; import gplx.Bool_;
import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.caches.*; import gplx.Bry_;
import gplx.Bry_bfr;
import gplx.Bry_bfr_;
import gplx.Byte_ascii;
import gplx.xowa.Xoa_ttl;
import gplx.xowa.Xowe_wiki;
import gplx.xowa.langs.kwds.Xol_kwd_grp_;
import gplx.xowa.parsers.Xop_ctx;
import gplx.xowa.wikis.caches.Xow_page_cache_itm;
import gplx.xowa.wikis.nss.Xow_ns;
import gplx.xowa.wikis.nss.Xow_ns_;
import gplx.xowa.wikis.nss.Xow_ns_mgr;
import gplx.xowa.xtns.pfuncs.Pf_func_base;
public class Xot_invk_tkn_ { public class Xot_invk_tkn_ {
public static void Eval_func(Xop_ctx ctx, byte[] src, Xot_invk caller, Xot_invk invk, Bry_bfr bfr, Xot_defn defn, byte[] argx_ary) { public static void Eval_func(Xop_ctx ctx, byte[] src, Xot_invk caller, Xot_invk invk, Bry_bfr bfr, Xot_defn defn, byte[] argx_ary) {
Pf_func_base defn_func = (Pf_func_base)defn; Pf_func_base defn_func = (Pf_func_base)defn;
@ -34,20 +47,6 @@ public class Xot_invk_tkn_ {
ctx.Page().Tmpl_prepend_mgr().End(ctx, bfr, bfr_func.Bfr(), bfr_func.Len(), Bool_.N); ctx.Page().Tmpl_prepend_mgr().End(ctx, bfr, bfr_func.Bfr(), bfr_func.Len(), Bool_.N);
bfr.Add_bfr_and_clear(bfr_func); bfr.Add_bfr_and_clear(bfr_func);
} }
public static void Bld_key(Xot_invk invk, byte[] name_ary, Bry_bfr bfr) {
bfr.Clear();
bfr.Add(name_ary);
int args_len = invk.Args_len();
for (int i = 0; i < args_len; i++) {
Arg_nde_tkn nde = invk.Args_get_by_idx(i);
bfr.Add_byte(Byte_ascii.Pipe);
if (nde.KeyTkn_exists()) {
bfr.Add(nde.Key_tkn().Dat_ary());
bfr.Add_byte(Byte_ascii.Eq);
}
bfr.Add(nde.Val_tkn().Dat_ary());
}
}
public static Xot_defn_tmpl Load_defn(Xowe_wiki wiki, Xop_ctx ctx, Xot_invk_tkn invk_tkn, Xoa_ttl ttl, byte[] name_ary) { // recursive loading of templates public static Xot_defn_tmpl Load_defn(Xowe_wiki wiki, Xop_ctx ctx, Xot_invk_tkn invk_tkn, Xoa_ttl ttl, byte[] name_ary) { // recursive loading of templates
Xow_page_cache_itm tmpl_page_itm = wiki.Cache_mgr().Page_cache().Get_itm_else_load_or_null(ttl); Xow_page_cache_itm tmpl_page_itm = wiki.Cache_mgr().Page_cache().Get_itm_else_load_or_null(ttl);
byte[] tmpl_page_bry = tmpl_page_itm == null ? null : tmpl_page_itm.Wtxt__direct(); byte[] tmpl_page_bry = tmpl_page_itm == null ? null : tmpl_page_itm.Wtxt__direct();

View File

@ -1,6 +1,6 @@
/* /*
XOWA: the XOWA Offline Wiki Application XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3, XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0. or alternatively under the terms of the Apache License Version 2.0.
@ -13,10 +13,35 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.wikis; import gplx.*; import gplx.xowa.*; package gplx.xowa.wikis;
import gplx.xowa.langs.*; import gplx.xowa.xtns.wbases.*;
import gplx.xowa.wikis.domains.*; import gplx.xowa.wikis.domains.crts.*; import gplx.xowa.wikis.nss.*; import gplx.xowa.wikis.metas.*; import gplx.xowa.langs.names.*; import gplx.Bry_;
import gplx.xowa.addons.wikis.directorys.dbs.*; import gplx.GfoMsg;
import gplx.Gfo_invk;
import gplx.Gfo_invk_;
import gplx.GfsCtx;
import gplx.Hash_adp_bry;
import gplx.Int_;
import gplx.Io_url;
import gplx.List_adp;
import gplx.List_adp_;
import gplx.String_;
import gplx.xowa.Xoae_app;
import gplx.xowa.Xow_wiki;
import gplx.xowa.Xowe_wiki;
import gplx.xowa.addons.wikis.directorys.dbs.Xowdir_db_mgr;
import gplx.xowa.addons.wikis.directorys.dbs.Xowdir_wiki_itm;
import gplx.xowa.langs.Xol_lang_itm;
import gplx.xowa.langs.Xol_lang_itm_;
import gplx.xowa.langs.Xol_lang_stub_;
import gplx.xowa.wikis.domains.Xow_domain_itm;
import gplx.xowa.wikis.domains.Xow_domain_itm_;
import gplx.xowa.wikis.domains.Xow_domain_tid_;
import gplx.xowa.wikis.metas.Xow_script_mgr;
import gplx.xowa.wikis.nss.Xow_ns_mgr;
import gplx.xowa.wikis.nss.Xow_ns_mgr_;
import gplx.xowa.xtns.wbases.Wdata_wiki_mgr;
public class Xoae_wiki_mgr implements Xoa_wiki_mgr, Gfo_invk { public class Xoae_wiki_mgr implements Xoa_wiki_mgr, Gfo_invk {
private final Xoae_app app; private final Xoae_app app;
private final List_adp list = List_adp_.New(); private final Hash_adp_bry hash = Hash_adp_bry.ci_a7(); // ASCII:url_domain; EX:en.wikipedia.org private final List_adp list = List_adp_.New(); private final Hash_adp_bry hash = Hash_adp_bry.ci_a7(); // ASCII:url_domain; EX:en.wikipedia.org
@ -107,7 +132,6 @@ public class Xoae_wiki_mgr implements Xoa_wiki_mgr, Gfo_invk {
// wiki.Defn_cache().ReduceCache(); // wiki.Defn_cache().ReduceCache();
if (clear_ctx) wiki.Parser_mgr().Ctx().Clear_all(); // NOTE: clear_ctx will reset toc and refs if (clear_ctx) wiki.Parser_mgr().Ctx().Clear_all(); // NOTE: clear_ctx will reset toc and refs
wiki.Cache_mgr().Page_cache().Free_mem(true); wiki.Cache_mgr().Page_cache().Free_mem(true);
wiki.Cache_mgr().Tmpl_result_cache().Clear();
} }
} }
public void Rls() { public void Rls() {

View File

@ -1,6 +1,6 @@
/* /*
XOWA: the XOWA Offline Wiki Application XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com Copyright (C) 2012-2020 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3, XOWA is licensed under the terms of the General Public License (GPL) Version 3,
or alternatively under the terms of the Apache License Version 2.0. or alternatively under the terms of the Apache License Version 2.0.
@ -13,9 +13,22 @@ The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/ */
package gplx.xowa.wikis.caches; import gplx.*; import gplx.xowa.*; import gplx.xowa.wikis.*; package gplx.xowa.wikis.caches;
import gplx.core.caches.*;
import gplx.xowa.wikis.xwikis.sitelinks.*; import gplx.Hash_adp;
import gplx.Hash_adp_;
import gplx.Hash_adp_bry;
import gplx.Io_mgr;
import gplx.Keyval;
import gplx.Keyval_;
import gplx.List_adp;
import gplx.List_adp_;
import gplx.String_;
import gplx.core.caches.Gfo_cache_mgr;
import gplx.xowa.Xowe_wiki;
import gplx.xowa.wikis.xwikis.sitelinks.Xoa_sitelink_itm;
import gplx.xowa.wikis.xwikis.sitelinks.Xoa_sitelink_itm_mgr;
public class Xow_cache_mgr { public class Xow_cache_mgr {
private final Xowe_wiki wiki; private final Xowe_wiki wiki;
public Xow_cache_mgr(Xowe_wiki wiki) { public Xow_cache_mgr(Xowe_wiki wiki) {
@ -24,7 +37,6 @@ public class Xow_cache_mgr {
this.defn_cache = new Xow_defn_cache(wiki.Lang()); this.defn_cache = new Xow_defn_cache(wiki.Lang());
this.ifexist_cache = new Xow_ifexist_cache(wiki, page_cache); this.ifexist_cache = new Xow_ifexist_cache(wiki, page_cache);
} }
public Hash_adp Tmpl_result_cache() {return tmpl_result_cache;} private final Hash_adp tmpl_result_cache = Hash_adp_bry.cs();
public Xow_defn_cache Defn_cache() {return defn_cache;} private final Xow_defn_cache defn_cache; public Xow_defn_cache Defn_cache() {return defn_cache;} private final Xow_defn_cache defn_cache;
public Hash_adp_bry Lst_cache() {return lst_cache;} private final Hash_adp_bry lst_cache = Hash_adp_bry.cs(); public Hash_adp_bry Lst_cache() {return lst_cache;} private final Hash_adp_bry lst_cache = Hash_adp_bry.cs();
public Hash_adp Misc_cache() {return misc_cache;} private final Hash_adp misc_cache = Hash_adp_.New(); public Hash_adp Misc_cache() {return misc_cache;} private final Hash_adp misc_cache = Hash_adp_.New();
@ -73,7 +85,6 @@ public class Xow_cache_mgr {
break; break;
} }
wiki.Ctg__catpage_mgr().Free_mem_all(); wiki.Ctg__catpage_mgr().Free_mem_all();
tmpl_result_cache.Clear();
defn_cache.Free_mem_all(); defn_cache.Free_mem_all();
lst_cache.Clear(); lst_cache.Clear();
misc_cache.Clear(); misc_cache.Clear();

View File

@ -1,20 +1,18 @@
/* package gplx.xowa.xtns.scribunto.libs;
XOWA: the XOWA Offline Wiki Application
Copyright (C) 2012-2017 gnosygnu@gmail.com
XOWA is licensed under the terms of the General Public License (GPL) Version 3, import gplx.Err_;
or alternatively under the terms of the Apache License Version 2.0. import gplx.Keyval_;
import gplx.Object_;
import gplx.String_;
import gplx.Tfds;
import gplx.xowa.xtns.scribunto.Scrib_core;
import gplx.xowa.xtns.scribunto.Scrib_invoke_func;
import gplx.xowa.xtns.scribunto.Scrib_invoke_func_fxt;
import gplx.xowa.xtns.scribunto.Scrib_kv_utl_;
import gplx.xowa.xtns.scribunto.Scrib_lib;
import org.junit.Before;
import org.junit.Test;
You may use XOWA according to either of these licenses as is most appropriate
for your project on a case-by-case basis.
The terms of each license can be found in the source code repository:
GPLv3 License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-GPLv3.txt
Apache License: https://github.com/gnosygnu/xowa/blob/master/LICENSE-APACHE2.txt
*/
package gplx.xowa.xtns.scribunto.libs; import gplx.*; import gplx.xowa.*; import gplx.xowa.xtns.*; import gplx.xowa.xtns.scribunto.*;
import org.junit.*;
public class Scrib_lib_mw__invoke_tst { public class Scrib_lib_mw__invoke_tst {
@Before public void init() { @Before public void init() {
fxt.Clear_for_invoke(); fxt.Clear_for_invoke();
@ -127,7 +125,6 @@ public class Scrib_lib_mw__invoke_tst {
fxt.Init_cbk(fxt.Core().Lib_mw(), Scrib_lib_mw.Invk_preprocess); fxt.Init_cbk(fxt.Core().Lib_mw(), Scrib_lib_mw.Invk_preprocess);
} }
private void Exec_preprocess(String frame, String arg_idx, String expd) { private void Exec_preprocess(String frame, String arg_idx, String expd) {
fxt.Parser_fxt().Wiki().Cache_mgr().Tmpl_result_cache().Clear();
fxt.Init_lua_module(); fxt.Init_lua_module();
fxt.Init_lua_rcvd_preprocess(frame, "{{#ifeq:" + arg_idx + "|{{{1}}}|{{{2}}}|{{{3}}}}}"); fxt.Init_lua_rcvd_preprocess(frame, "{{#ifeq:" + arg_idx + "|{{{1}}}|{{{2}}}|{{{3}}}}}");
fxt.Test_invoke(expd); fxt.Test_invoke(expd);