Skip to content

Commit

Permalink
模型表新增设置UsingCache,支持关闭缓存。某些表,例如设备在线表,它不是大数据表,而是实时表,也不用缓存
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Jul 7, 2024
1 parent ceb7f8a commit 4336f76
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
26 changes: 23 additions & 3 deletions XCode/Code/EntityBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ public static void FixModelFile(String xmlFile, BuilderOption option, IDictionar
}
}

// 使用缓存
foreach (var table in tables)
{
var cache = table.Properties["UsingCache"];
if (!cache.IsNullOrEmpty() && !cache.ToBoolean(true))
table.Properties["UsingCache"] = false.ToString();
else
table.Properties.Remove("UsingCache");
}

// 更新xsd
atts["xmlns"] = "https://newlifex.com/Model202407.xsd";
atts["xs:schemaLocation"] = "https://newlifex.com https://newlifex.com/Model202407.xsd";
Expand Down Expand Up @@ -271,9 +281,19 @@ public override void Load(IDataTable table)
else if (!modelClass.IsNullOrEmpty())
option.ModelNameForCopy = modelClass;

// 标记为大数据的表不使用缓存
var fi = table.Columns.FirstOrDefault(e => e.DataScale.EqualIgnoreCase("time") || e.DataScale.StartsWithIgnoreCase("time:", "timeShard:"));
if (fi != null) UsingCache = false;
// 使用缓存
if (UsingCache)
{
var cache = table.Properties["UsingCache"];
if (!cache.IsNullOrEmpty() && !cache.ToBoolean(true)) UsingCache = false;
}

if (UsingCache)
{
// 标记为大数据的表不使用缓存
var fi = table.Columns.FirstOrDefault(e => e.DataScale.EqualIgnoreCase("time") || e.DataScale.StartsWithIgnoreCase("time:", "timeShard:"));
if (fi != null) UsingCache = false;
}
}

#endregion 方法
Expand Down
2 changes: 1 addition & 1 deletion XCode/Membership/Member.xml
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
<Index Columns="ParentID,Name" Unique="True" />
</Indexes>
</Table>
<Table Name="Parameter" Description="字典参数。管理用户或系统全局的名值对数据,常用于参数配置场合">
<Table Name="Parameter" Description="字典参数。管理用户或系统全局的名值对数据,常用于参数配置场合" UsingCache="False">
<Columns>
<Column Name="ID" DataType="Int32" Identity="True" PrimaryKey="True" Description="编号" />
<Column Name="UserID" DataType="Int32" Map="User@Id@$" Description="用户。按用户区分参数,用户0表示系统级" />
Expand Down
Binary file modified XCode/Membership/xcodetool.exe
Binary file not shown.
9 changes: 8 additions & 1 deletion XCode/ModelSchema.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,14 @@
<xs:attribute name="InsertOnly" type="BooleanType">
<xs:annotation>
<xs:documentation xml:lang="zh-cn">
仅插入数据,比如日志型
仅插入数据,比如日志表、记录表、事件表等
</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="UsingCache" type="BooleanType">
<xs:annotation>
<xs:documentation xml:lang="zh-cn">
使用缓存。生成Find/FindAll等方法时是否使用缓存
</xs:documentation>
</xs:annotation>
</xs:attribute>
Expand Down

0 comments on commit 4336f76

Please sign in to comment.