数据库缓存更新

This commit is contained in:
hoteas 2018-04-09 17:16:24 +00:00
parent 546058513f
commit e5eaa97ff9
8 changed files with 446 additions and 205 deletions

View File

@ -6,9 +6,13 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" readonly="true" id="03ed5703-81a1-441b-849c-c426276586b7" name="Default" comment=""> <list default="true" readonly="true" id="03ed5703-81a1-441b-849c-c426276586b7" name="Default" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
<change beforePath="$PROJECT_DIR$/example/config/config.json" afterPath="$PROJECT_DIR$/example/config/config.json" /> <change beforePath="$PROJECT_DIR$/cache/cache_redis.go" afterPath="$PROJECT_DIR$/cache/cache_redis.go" />
<change beforePath="$PROJECT_DIR$/cache_db.go" afterPath="$PROJECT_DIR$/cache_db.go" />
<change beforePath="$PROJECT_DIR$/cache_memory.go" afterPath="$PROJECT_DIR$/cache_memory.go" />
<change beforePath="$PROJECT_DIR$/db.go" afterPath="$PROJECT_DIR$/db.go" />
<change beforePath="$PROJECT_DIR$/example/main.go" afterPath="$PROJECT_DIR$/example/main.go" /> <change beforePath="$PROJECT_DIR$/example/main.go" afterPath="$PROJECT_DIR$/example/main.go" />
<change beforePath="$PROJECT_DIR$/example/tpt/index.html" afterPath="$PROJECT_DIR$/example/tpt/index.html" /> <change beforePath="$PROJECT_DIR$/obj.go" afterPath="$PROJECT_DIR$/obj.go" />
<change beforePath="$PROJECT_DIR$/objtoobj.go" afterPath="$PROJECT_DIR$/objtoobj.go" />
</list> </list>
<ignored path=".idea/dataSources.local.xml" /> <ignored path=".idea/dataSources.local.xml" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
@ -29,30 +33,20 @@
<file leaf-file-name="main.go" pinned="false" current-in-tab="true"> <file leaf-file-name="main.go" pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/example/main.go"> <entry file="file://$PROJECT_DIR$/example/main.go">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="256"> <state relative-caret-position="220">
<caret line="82" column="31" lean-forward="true" selection-start-line="82" selection-start-column="31" selection-end-line="82" selection-end-column="31" /> <caret line="88" column="43" lean-forward="true" selection-start-line="88" selection-start-column="43" selection-end-line="88" selection-end-column="43" />
<folding> <folding>
<element signature="e#14#177#0" expanded="true" /> <element signature="e#14#207#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="index.html" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/example/tpt/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165">
<caret line="11" column="0" lean-forward="false" selection-start-line="11" selection-start-column="0" selection-end-line="11" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="type.go" pinned="false" current-in-tab="false"> <file leaf-file-name="type.go" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/type.go"> <entry file="file://$PROJECT_DIR$/type.go">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165"> <state relative-caret-position="105">
<caret line="11" column="4" lean-forward="false" selection-start-line="11" selection-start-column="4" selection-end-line="11" selection-end-column="4" /> <caret line="7" column="13" lean-forward="false" selection-start-line="7" selection-start-column="5" selection-end-line="7" selection-end-column="13" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -61,8 +55,8 @@
<file leaf-file-name="cache_redis.go" pinned="false" current-in-tab="false"> <file leaf-file-name="cache_redis.go" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/cache/cache_redis.go"> <entry file="file://$PROJECT_DIR$/cache/cache_redis.go">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1575"> <state relative-caret-position="180">
<caret line="110" column="50" lean-forward="false" selection-start-line="110" selection-start-column="50" selection-end-line="110" selection-end-column="50" /> <caret line="12" column="14" lean-forward="true" selection-start-line="12" selection-start-column="14" selection-end-line="12" selection-end-column="14" />
<folding> <folding>
<element signature="e#15#106#0" expanded="true" /> <element signature="e#15#106#0" expanded="true" />
</folding> </folding>
@ -70,11 +64,11 @@
</provider> </provider>
</entry> </entry>
</file> </file>
<file leaf-file-name="strings.go" pinned="false" current-in-tab="false"> <file leaf-file-name="cache_memory.go" pinned="false" current-in-tab="false">
<entry file="file://D:/app/go/src/strings/strings.go"> <entry file="file://$PROJECT_DIR$/cache_memory.go">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1335"> <state relative-caret-position="225">
<caret line="92" column="15" lean-forward="false" selection-start-line="92" selection-start-column="15" selection-end-line="92" selection-end-column="15" /> <caret line="19" column="18" lean-forward="true" selection-start-line="19" selection-start-column="18" selection-end-line="19" selection-end-column="18" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -83,38 +77,8 @@
<file leaf-file-name="objtoobj.go" pinned="false" current-in-tab="false"> <file leaf-file-name="objtoobj.go" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/objtoobj.go"> <entry file="file://$PROJECT_DIR$/objtoobj.go">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2985"> <state relative-caret-position="255">
<caret line="204" column="5" lean-forward="false" selection-start-line="204" selection-start-column="5" selection-end-line="204" selection-end-column="5" /> <caret line="52" column="18" lean-forward="false" selection-start-line="52" selection-start-column="18" selection-end-line="52" selection-end-column="18" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="cache_memory.go" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/cache_memory.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="915">
<caret line="64" column="0" lean-forward="false" selection-start-line="64" selection-start-column="0" selection-end-line="64" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="config.json" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/example/config/config.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="210">
<caret line="14" column="17" lean-forward="false" selection-start-line="14" selection-start-column="17" selection-end-line="14" selection-end-column="17" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="cache_db.go" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/cache_db.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="105">
<caret line="10" column="10" lean-forward="false" selection-start-line="10" selection-start-column="10" selection-end-line="10" selection-end-column="10" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -123,8 +87,48 @@
<file leaf-file-name="db.go" pinned="false" current-in-tab="false"> <file leaf-file-name="db.go" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/db.go"> <entry file="file://$PROJECT_DIR$/db.go">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="4860"> <state relative-caret-position="370">
<caret line="331" column="27" lean-forward="false" selection-start-line="331" selection-start-column="27" selection-end-line="331" selection-end-column="27" /> <caret line="893" column="9" lean-forward="true" selection-start-line="893" selection-start-column="9" selection-end-line="893" selection-end-column="9" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="error.go" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/error.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="135">
<caret line="11" column="17" lean-forward="false" selection-start-line="11" selection-start-column="17" selection-end-line="11" selection-end-column="17" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="obj.go" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/obj.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="468">
<caret line="66" column="24" lean-forward="false" selection-start-line="66" selection-start-column="24" selection-end-line="66" selection-end-column="24" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="cache_db.go" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/cache_db.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="281">
<caret line="77" column="51" lean-forward="false" selection-start-line="77" selection-start-column="51" selection-end-line="77" selection-end-column="51" />
<folding />
</state>
</provider>
</entry>
</file>
<file leaf-file-name="func.go" pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/func.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-765">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding /> <folding />
</state> </state>
</provider> </provider>
@ -148,6 +152,11 @@
<find>GetString</find> <find>GetString</find>
<find>CacheMemory</find> <find>CacheMemory</find>
<find>GetTag</find> <find>GetTag</find>
<find>copy</find>
<find>Cached</find>
<find>md5</find>
<find>Query</find>
<find>cacheMutex</find>
</findStrings> </findStrings>
<replaceStrings> <replaceStrings>
<replace>MUTEX_SESSION_TYPE</replace> <replace>MUTEX_SESSION_TYPE</replace>
@ -163,7 +172,6 @@
<component name="IdeDocumentHistory"> <component name="IdeDocumentHistory">
<option name="CHANGED_PATHS"> <option name="CHANGED_PATHS">
<list> <list>
<option value="$PROJECT_DIR$/objtoobj.go" />
<option value="$PROJECT_DIR$/controller.go" /> <option value="$PROJECT_DIR$/controller.go" />
<option value="$PROJECT_DIR$/Config.go" /> <option value="$PROJECT_DIR$/Config.go" />
<option value="$PROJECT_DIR$/config.go" /> <option value="$PROJECT_DIR$/config.go" />
@ -176,11 +184,8 @@
<option value="$PROJECT_DIR$/base.go" /> <option value="$PROJECT_DIR$/base.go" />
<option value="$PROJECT_DIR$/base_context.go" /> <option value="$PROJECT_DIR$/base_context.go" />
<option value="$PROJECT_DIR$/context_base.go" /> <option value="$PROJECT_DIR$/context_base.go" />
<option value="$PROJECT_DIR$/obj.go" />
<option value="$PROJECT_DIR$/cache_db.go" />
<option value="$PROJECT_DIR$/context.go" /> <option value="$PROJECT_DIR$/context.go" />
<option value="$PROJECT_DIR$/config/config.json" /> <option value="$PROJECT_DIR$/config/config.json" />
<option value="$PROJECT_DIR$/db.go" />
<option value="$PROJECT_DIR$/manage/manage.go" /> <option value="$PROJECT_DIR$/manage/manage.go" />
<option value="$PROJECT_DIR$/slice.go" /> <option value="$PROJECT_DIR$/slice.go" />
<option value="$PROJECT_DIR$/dri/upload/upload.go" /> <option value="$PROJECT_DIR$/dri/upload/upload.go" />
@ -191,12 +196,16 @@
<option value="$PROJECT_DIR$/const.go" /> <option value="$PROJECT_DIR$/const.go" />
<option value="$PROJECT_DIR$/func.go" /> <option value="$PROJECT_DIR$/func.go" />
<option value="$PROJECT_DIR$/error.go" /> <option value="$PROJECT_DIR$/error.go" />
<option value="$PROJECT_DIR$/cache_memory.go" />
<option value="$PROJECT_DIR$/cache_redis.go" /> <option value="$PROJECT_DIR$/cache_redis.go" />
<option value="$PROJECT_DIR$/type.go" /> <option value="$PROJECT_DIR$/type.go" />
<option value="$PROJECT_DIR$/cache/cache_redis.go" />
<option value="$PROJECT_DIR$/example/config/config.json" /> <option value="$PROJECT_DIR$/example/config/config.json" />
<option value="$PROJECT_DIR$/example/tpt/index.html" /> <option value="$PROJECT_DIR$/example/tpt/index.html" />
<option value="$PROJECT_DIR$/obj.go" />
<option value="$PROJECT_DIR$/objtoobj.go" />
<option value="$PROJECT_DIR$/cache_memory.go" />
<option value="$PROJECT_DIR$/cache_db.go" />
<option value="$PROJECT_DIR$/cache/cache_redis.go" />
<option value="$PROJECT_DIR$/db.go" />
<option value="$PROJECT_DIR$/example/main.go" /> <option value="$PROJECT_DIR$/example/main.go" />
</list> </list>
</option> </option>
@ -211,9 +220,9 @@
<servers /> <servers />
</component> </component>
<component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" /> <component name="PhpWorkspaceProjectConfiguration" backward_compatibility_performed="true" />
<component name="ProjectFrameBounds"> <component name="ProjectFrameBounds" extendedState="6">
<option name="x" value="55" /> <option name="x" value="-673" />
<option name="y" value="-8" /> <option name="y" value="310" />
<option name="width" value="1873" /> <option name="width" value="1873" />
<option name="height" value="1084" /> <option name="height" value="1084" />
</component> </component>
@ -232,6 +241,10 @@
<foldersAlwaysOnTop value="true" /> <foldersAlwaysOnTop value="true" />
</navigator> </navigator>
<panes> <panes>
<pane id="PackagesPane" />
<pane id="Scratches" />
<pane id="AndroidView" />
<pane id="Scope" />
<pane id="ProjectPane"> <pane id="ProjectPane">
<subPane> <subPane>
<expand> <expand>
@ -265,10 +278,6 @@
<select /> <select />
</subPane> </subPane>
</pane> </pane>
<pane id="Scope" />
<pane id="AndroidView" />
<pane id="Scratches" />
<pane id="PackagesPane" />
</panes> </panes>
</component> </component>
<component name="PropertiesComponent"> <component name="PropertiesComponent">
@ -473,7 +482,8 @@
<workItem from="1522778115746" duration="44000" /> <workItem from="1522778115746" duration="44000" />
<workItem from="1522778659126" duration="455000" /> <workItem from="1522778659126" duration="455000" />
<workItem from="1522779789231" duration="6991000" /> <workItem from="1522779789231" duration="6991000" />
<workItem from="1523202491878" duration="835000" /> <workItem from="1523202491878" duration="853000" />
<workItem from="1523288830673" duration="5049000" />
</task> </task>
<task id="LOCAL-00001"> <task id="LOCAL-00001">
<created>1500458878821</created> <created>1500458878821</created>
@ -671,11 +681,18 @@
<option name="project" value="LOCAL" /> <option name="project" value="LOCAL" />
<updated>1522782970484</updated> <updated>1522782970484</updated>
</task> </task>
<option name="localTasksCounter" value="29" /> <task id="LOCAL-00029" summary="工具">
<created>1523203335093</created>
<option name="number" value="00029" />
<option name="presentableId" value="LOCAL-00029" />
<option name="project" value="LOCAL" />
<updated>1523203335093</updated>
</task>
<option name="localTasksCounter" value="30" />
<servers /> <servers />
</component> </component>
<component name="TimeTrackingManager"> <component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="101505000" /> <option name="totallyTimeSpent" value="106572000" />
</component> </component>
<component name="TodoView"> <component name="TodoView">
<todo-panel id="selected-file"> <todo-panel id="selected-file">
@ -687,7 +704,7 @@
</todo-panel> </todo-panel>
</component> </component>
<component name="ToolWindowManager"> <component name="ToolWindowManager">
<frame x="55" y="-8" width="1873" height="1084" extended-state="0" /> <frame x="54" y="-8" width="1874" height="1096" extended-state="6" />
<editor active="true" /> <editor active="true" />
<layout> <layout>
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32846716" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" /> <window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32846716" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
@ -696,12 +713,12 @@
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" /> <window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.32911393" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.328125" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.6329114" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.6322917" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32805908" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" /> <window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32805908" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Capture Tool" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" /> <window_info id="Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.37341422" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" /> <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.22657111" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
<window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" /> <window_info id="Database" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.24972437" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.24972437" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" /> <window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
@ -745,7 +762,91 @@
<state relative-caret-position="0"> <state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding> <folding>
<element signature="e#14#177#0" expanded="true" /> <element signature="e#14#207#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/tpt/index.html">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165">
<caret line="11" column="0" lean-forward="false" selection-start-line="11" selection-start-column="0" selection-end-line="11" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/type.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165">
<caret line="11" column="4" lean-forward="false" selection-start-line="11" selection-start-column="4" selection-end-line="11" selection-end-column="4" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/cache/cache_redis.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1575">
<caret line="110" column="50" lean-forward="false" selection-start-line="110" selection-start-column="50" selection-end-line="110" selection-end-column="50" />
<folding>
<element signature="e#15#106#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://D:/app/go/src/strings/strings.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1335">
<caret line="92" column="15" lean-forward="false" selection-start-line="92" selection-start-column="15" selection-end-line="92" selection-end-column="15" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/objtoobj.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2985">
<caret line="204" column="5" lean-forward="false" selection-start-line="204" selection-start-column="5" selection-end-line="204" selection-end-column="5" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/cache_memory.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="915">
<caret line="64" column="0" lean-forward="false" selection-start-line="64" selection-start-column="0" selection-end-line="64" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/config/config.json">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="210">
<caret line="14" column="17" lean-forward="false" selection-start-line="14" selection-start-column="17" selection-end-line="14" selection-end-column="17" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/cache_db.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="105">
<caret line="10" column="10" lean-forward="false" selection-start-line="10" selection-start-column="10" selection-end-line="10" selection-end-column="10" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/db.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="4860">
<caret line="331" column="27" lean-forward="false" selection-start-line="331" selection-start-column="27" selection-end-line="331" selection-end-column="27" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/main.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding>
<element signature="e#14#207#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -820,7 +921,6 @@
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="195"> <state relative-caret-position="195">
<caret line="13" column="16" lean-forward="true" selection-start-line="13" selection-start-column="16" selection-end-line="13" selection-end-column="16" /> <caret line="13" column="16" lean-forward="true" selection-start-line="13" selection-start-column="16" selection-end-line="13" selection-end-column="16" />
<folding />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -829,7 +929,7 @@
<state relative-caret-position="270"> <state relative-caret-position="270">
<caret line="18" column="29" lean-forward="false" selection-start-line="18" selection-start-column="29" selection-end-line="18" selection-end-column="29" /> <caret line="18" column="29" lean-forward="false" selection-start-line="18" selection-start-column="29" selection-end-line="18" selection-end-column="29" />
<folding> <folding>
<element signature="e#14#177#0" expanded="true" /> <element signature="e#14#207#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -847,7 +947,7 @@
<state relative-caret-position="0"> <state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" /> <caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding> <folding>
<element signature="e#14#177#0" expanded="true" /> <element signature="e#14#207#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>
@ -865,23 +965,6 @@
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="195"> <state relative-caret-position="195">
<caret line="13" column="16" lean-forward="false" selection-start-line="13" selection-start-column="16" selection-end-line="13" selection-end-column="16" /> <caret line="13" column="16" lean-forward="false" selection-start-line="13" selection-start-column="16" selection-end-line="13" selection-end-column="16" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/cache_memory.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="915">
<caret line="64" column="0" lean-forward="false" selection-start-line="64" selection-start-column="0" selection-end-line="64" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/objtoobj.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2985">
<caret line="204" column="5" lean-forward="false" selection-start-line="204" selection-start-column="5" selection-end-line="204" selection-end-column="5" />
<folding />
</state> </state>
</provider> </provider>
</entry> </entry>
@ -893,40 +976,6 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/type.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="165">
<caret line="11" column="4" lean-forward="false" selection-start-line="11" selection-start-column="4" selection-end-line="11" selection-end-column="4" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/cache/cache_redis.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="1575">
<caret line="110" column="50" lean-forward="false" selection-start-line="110" selection-start-column="50" selection-end-line="110" selection-end-column="50" />
<folding>
<element signature="e#15#106#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/cache_db.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="105">
<caret line="10" column="10" lean-forward="false" selection-start-line="10" selection-start-column="10" selection-end-line="10" selection-end-column="10" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/db.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="4860">
<caret line="331" column="27" lean-forward="false" selection-start-line="331" selection-start-column="27" selection-end-line="331" selection-end-column="27" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/config/config.json"> <entry file="file://$PROJECT_DIR$/example/config/config.json">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="210"> <state relative-caret-position="210">
@ -943,12 +992,94 @@
</state> </state>
</provider> </provider>
</entry> </entry>
<entry file="file://$PROJECT_DIR$/var.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="0">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/type.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="105">
<caret line="7" column="13" lean-forward="false" selection-start-line="7" selection-start-column="5" selection-end-line="7" selection-end-column="13" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/func.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="-765">
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/obj.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="468">
<caret line="66" column="24" lean-forward="false" selection-start-line="66" selection-start-column="24" selection-end-line="66" selection-end-column="24" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/error.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="135">
<caret line="11" column="17" lean-forward="false" selection-start-line="11" selection-start-column="17" selection-end-line="11" selection-end-column="17" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/cache/cache_redis.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="180">
<caret line="12" column="14" lean-forward="true" selection-start-line="12" selection-start-column="14" selection-end-line="12" selection-end-column="14" />
<folding>
<element signature="e#15#106#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/cache_memory.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="225">
<caret line="19" column="18" lean-forward="true" selection-start-line="19" selection-start-column="18" selection-end-line="19" selection-end-column="18" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/objtoobj.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="255">
<caret line="52" column="18" lean-forward="false" selection-start-line="52" selection-start-column="18" selection-end-line="52" selection-end-column="18" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/db.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="370">
<caret line="893" column="9" lean-forward="true" selection-start-line="893" selection-start-column="9" selection-end-line="893" selection-end-column="9" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/cache_db.go">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="281">
<caret line="77" column="51" lean-forward="false" selection-start-line="77" selection-start-column="51" selection-end-line="77" selection-end-column="51" />
<folding />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/example/main.go"> <entry file="file://$PROJECT_DIR$/example/main.go">
<provider selected="true" editor-type-id="text-editor"> <provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="256"> <state relative-caret-position="220">
<caret line="82" column="31" lean-forward="true" selection-start-line="82" selection-start-column="31" selection-end-line="82" selection-end-column="31" /> <caret line="88" column="43" lean-forward="true" selection-start-line="88" selection-start-column="43" selection-end-line="88" selection-end-column="43" />
<folding> <folding>
<element signature="e#14#177#0" expanded="true" /> <element signature="e#14#207#0" expanded="true" />
</folding> </folding>
</state> </state>
</provider> </provider>

91
cache/cache_redis.go vendored
View File

@ -42,19 +42,51 @@ func (this *CacheRedis) reCon()bool{
} }
return true return true
} }
func (this *CacheRedis) del(key string) {
del:=strings.Index(key,"*")
if del!=-1{
val, err := redis.Strings(this.conn.Do("KEYS", key))
if err!=nil{
return
}
this.conn.Send("MULTI")
for i, _ := range val {
this.conn.Send("DEL", val[i])
}
this.conn.Do("EXEC")
}else{
_,err:=this.conn.Do("DEL",key)
if err!=nil{
this.Error.SetError(err)
_,err=this.conn.Do("PING")
if err!=nil{
if this.reCon(){
_,err=this.conn.Do("DEL",key)
}
}
}
}
}
func (this *CacheRedis) Cache(key string, data ...interface{}) *Obj { //key value ,时间为时间戳
func (this *CacheRedis) set(key string, value string, time int64) {
_,err:=this.conn.Do("SET",key,value,"EX",ObjToStr(time))
if err!=nil{
this.Error.SetError(err)
_,err=this.conn.Do("PING")
if err!=nil{
if this.reCon(){
_,err=this.conn.Do("SET",key,value,"EX",ObjToStr(time))
}
}
}
}
func (this *CacheRedis) get(key string) *Obj{
reData:= &Obj{} reData:= &Obj{}
var err error var err error
if this.conn==nil{
re:=this.reCon()
if !re{
return reData
}
}
//查询缓存
if len(data) == 0 {
reData.Data, err = redis.String(this.conn.Do("GET", key)) reData.Data, err = redis.String(this.conn.Do("GET", key))
if err != nil { if err != nil {
reData.Data=nil reData.Data=nil
@ -71,22 +103,27 @@ func (this *CacheRedis) Cache(key string, data ...interface{}) *Obj {
} }
} }
return reData return reData
}
func (this *CacheRedis) Cache(key string, data ...interface{}) *Obj {
reData:= &Obj{}
if this.conn==nil{
re:=this.reCon()
if !re{
return reData
}
}
//查询缓存
if len(data) == 0 {
reData=this.get(key)
return reData
} }
tim := int64(0) tim := int64(0)
//删除缓存 //删除缓存
if len(data) == 1 && data[0] == nil { if len(data) == 1 && data[0] == nil {
this.del(key)
_,err=this.conn.Do("DEL",key)
if err!=nil{
this.Error.SetError(err)
_,err=this.conn.Do("PING")
if err!=nil{
if this.reCon(){
_,err=this.conn.Do("DEL",key)
}
}
}
return reData return reData
} }
//添加缓存 //添加缓存
@ -108,17 +145,9 @@ func (this *CacheRedis) Cache(key string, data ...interface{}) *Obj {
} }
} }
_,err=this.conn.Do("SET",key,ObjToStr(data[0]),"EX",ObjToStr(tim))
if err!=nil{
this.Error.SetError(err) this.set(key,ObjToStr(data[0]),tim)
_,err=this.conn.Do("PING")
if err!=nil{
if this.reCon(){
_,err=this.conn.Do("SET",key,ObjToStr(data[0]),"EX",ObjToStr(tim))
}
}
}
return reData return reData
} }

View File

@ -3,6 +3,7 @@ package hotime
import ( import (
"encoding/json" "encoding/json"
"time" "time"
"strings"
) )
type CacheDb struct { type CacheDb struct {
@ -69,8 +70,17 @@ func (this *CacheDb) set(key string, value interface{}, tim int64) {
} }
func (this *CacheDb) delete(key string) { func (this *CacheDb) delete(key string) {
del:=strings.Index(key,"*")
//如果通配删除
if del!=-1{
key=Substr(key,0,del)
this.Db.Delete("cached", Map{"ckey": key+"%"})
}else{
this.Db.Delete("cached", Map{"ckey": key}) this.Db.Delete("cached", Map{"ckey": key})
} }
}
func (this *CacheDb) Cache(key string, data ...interface{}) *Obj { func (this *CacheDb) Cache(key string, data ...interface{}) *Obj {

View File

@ -3,6 +3,7 @@ package hotime
import ( import (
"time" "time"
"sync" "sync"
"strings"
) )
type CacheMemory struct { type CacheMemory struct {
@ -70,9 +71,21 @@ func (this *CacheMemory) set(key string, value interface{}, time int64) {
} }
func (this *CacheMemory) delete(key string) { func (this *CacheMemory) delete(key string) {
del:=strings.Index(key,"*")
//如果通配删除
if del!=-1{
key=Substr(key,0,del)
for k,_:=range this.Map{
if strings.Index(k,key)!=-1{
delete(this.Map, key) delete(this.Map, key)
} }
}
}else{
delete(this.Map, key)
}
}
func (this *CacheMemory) Cache(key string, data ...interface{}) *Obj { func (this *CacheMemory) Cache(key string, data ...interface{}) *Obj {

77
db.go
View File

@ -7,13 +7,13 @@ import (
"os" "os"
"reflect" "reflect"
"strings" "strings"
"sync"
) )
type HoTimeDB struct { type HoTimeDB struct {
*sql.DB *sql.DB
contextBase contextBase
CacheIns
Cached bool
LastQuery string LastQuery string
LastData []interface{} LastData []interface{}
ConnectFunc func(err ...*Error) *sql.DB ConnectFunc func(err ...*Error) *sql.DB
@ -31,7 +31,7 @@ func (this *HoTimeDB) SetConnect(connect func(err ...*Error) *sql.DB, err ...*Er
//事务如果action返回true则执行成功false则回滚 //事务如果action返回true则执行成功false则回滚
func (this *HoTimeDB) Action(action func(db HoTimeDB) bool) bool { func (this *HoTimeDB) Action(action func(db HoTimeDB) bool) bool {
db := HoTimeDB{DB: this.DB, Cached: this.Cached} db := HoTimeDB{DB: this.DB,CacheIns:this.CacheIns}
tx, err := db.Begin() tx, err := db.Begin()
if err != nil { if err != nil {
this.LastErr.SetError(err) this.LastErr.SetError(err)
@ -426,11 +426,32 @@ func (this *HoTimeDB) Select(table string, qu ...interface{}) []Map {
query += temp query += temp
qs = append(qs, resWhere...) qs = append(qs, resWhere...)
md5:=this.md5(query,qs...)
//如果缓存有则从缓存取
cacheData:=this.Cache(table+":"+md5)
res := this.Query(query, qs...) if cacheData.Data!=nil{
if res == nil { return cacheData.ToMapArray()
return []Map{}
} }
//无缓存则数据库取
res := this.Query(query, qs...)
if res == nil {
res=[]Map{}
}
//缓存
if this.CacheIns!=nil{
this.Cache(table+":"+md5,res)
}
return res return res
} }
@ -796,13 +817,18 @@ func (this *HoTimeDB) Update(table string, data Map, where Map) int64 {
res, err := this.Exec(query, qs...) res, err := this.Exec(query, qs...)
if err.GetError() != nil { rows:=int64(0)
if err.GetError() == nil {
return 0 rows, _ = res.RowsAffected()
}
//如果更新成功,则删除缓存
if rows!=0{
if this.CacheIns!=nil{
this.Cache(table+"*",nil)
}
} }
//return 0
rows, _ := res.RowsAffected()
return rows return rows
} }
@ -814,13 +840,19 @@ func (this *HoTimeDB) Delete(table string, data map[string]interface{}) int64 {
query += temp query += temp
res, err := this.Exec(query, resWhere...) res, err := this.Exec(query, resWhere...)
rows:=int64(0)
if err.GetError() != nil { if err.GetError() == nil {
return 0 rows, _ = res.RowsAffected()
} }
//如果删除成功,删除对应缓存
if rows!=0{
if this.CacheIns!=nil{
this.Cache(table+"*",nil)
}
}
//return 0 //return 0
rows, _ := res.RowsAffected()
return rows return rows
} }
@ -849,16 +881,19 @@ func (this *HoTimeDB) Insert(table string, data map[string]interface{}) int64 {
res, err := this.Exec(query, values...) res, err := this.Exec(query, values...)
if err.GetError() != nil { id:=int64(0)
if err.GetError() == nil {
id, this.LastErr.err = res.LastInsertId()
return 0
} }
id, e := res.LastInsertId() //如果插入成功,删除缓存
this.LastErr.SetError(e) if id!=0{
if e != nil { if this.CacheIns!=nil{
return 0 this.Cache(table+"*",nil)
} }
}
//fmt.Println(id) //fmt.Println(id)
return id return id
} }

View File

@ -8,13 +8,12 @@ import (
//"go.hoteas.com/hotime/cache" //"go.hoteas.com/hotime/cache"
"golang.org/x/net/websocket" "golang.org/x/net/websocket"
"time" "time"
"go.hoteas.com/hotime/cache"
) )
func main() { func main() {
appIns := hotime.Application{} appIns := hotime.Application{}
@ -32,8 +31,14 @@ func main() {
//手动模式, //手动模式,
appIns.SetConfig("example/config/config.json") appIns.SetConfig("example/config/config.json")
//redis缓存接入
//ca:=hotime.CacheIns(&cache.CacheRedis{Host:appIns.Config.GetString("redisHost"),Pwd:appIns.Config.GetString("redisPwd"),Time:appIns.Config.GetCeilInt64("cacheLongTime")}) //ca:=hotime.CacheIns(&cache.CacheRedis{Host:appIns.Config.GetString("redisHost"),Pwd:appIns.Config.GetString("redisPwd"),Time:appIns.Config.GetCeilInt64("cacheLongTime")})
//ca.Cache("xyzm","dasdas")
//ca.Cache("xyzn","dasdas")
//ca.Cache("xyzo","dasdas")
//ca.Cache("xyz*",nil)
//fmt.Println(ca.Cache("xyzm").Data)
appIns.SetConnectDB(func(err ...*hotime.Error) *sql.DB { appIns.SetConnectDB(func(err ...*hotime.Error) *sql.DB {
query := appIns.Config.GetString("dbUser") + ":" + appIns.Config.GetString("dbPwd") + query := appIns.Config.GetString("dbUser") + ":" + appIns.Config.GetString("dbPwd") +

8
obj.go
View File

@ -60,6 +60,14 @@ func (this *Obj) ToSlice(err ...Error) Slice {
return ObjToSlice(this.Data, &this.Error) return ObjToSlice(this.Data, &this.Error)
} }
func (this *Obj)ToMapArray(err ...Error)[]Map{
if len(err) != 0 {
this.Error = err[0]
}
return ObjToMapArray(this.Data, &this.Error)
}
func (this *Obj) ToObj() interface{} { func (this *Obj) ToObj() interface{} {
return this.Data return this.Data

View File

@ -49,6 +49,16 @@ func ObjToMap(obj interface{}, e ...*Error) Map {
return v return v
} }
func ObjToMapArray(obj interface{}, e ...*Error) []Map {
s:=ObjToSlice(obj,e...)
res:=[]Map{}
for i:=0;i<len(s);i++{
res=append(res,s.GetMap(i))
}
return res
}
//仅限于hotime.Slice //仅限于hotime.Slice
func ObjToSlice(obj interface{}, e ...*Error) Slice { func ObjToSlice(obj interface{}, e ...*Error) Slice {
var err error var err error