diff options
| author | ruki <[email protected]> | 2020-12-22 00:48:16 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-12-22 00:48:16 +0800 |
| commit | 4782a9648e20c0e6a4620f7255ab3cb476dceb5e (patch) | |
| tree | b28369f767800262db24da6b347d62acf8ffad33 /xmake/core/cache | |
| parent | 192f10c1d09e665f04dd5669fcaccc5abccbb9db (diff) | |
rewrite some caches
Diffstat (limited to 'xmake/core/cache')
| -rw-r--r-- | xmake/core/cache/configcache.lua | 22 | ||||
| -rw-r--r-- | xmake/core/cache/globalcache.lua | 14 | ||||
| -rw-r--r-- | xmake/core/cache/localcache.lua | 14 |
3 files changed, 50 insertions, 0 deletions
diff --git a/xmake/core/cache/configcache.lua b/xmake/core/cache/configcache.lua new file mode 100644 index 000000000..889f7d1c4 --- /dev/null +++ b/xmake/core/cache/configcache.lua @@ -0,0 +1,22 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-present, TBOOX Open Source Group. +-- +-- @author ruki +-- @file configcache.lua +-- + +return require("cache/localcache").cache("config") + diff --git a/xmake/core/cache/globalcache.lua b/xmake/core/cache/globalcache.lua index 812cf25f1..fbed27408 100644 --- a/xmake/core/cache/globalcache.lua +++ b/xmake/core/cache/globalcache.lua @@ -172,6 +172,20 @@ function globalcache.set3(cachename, key1, key2, key3, value) return globalcache.cache(cachename):set3(key1, key2, key3, value) end +-- save the given cache, it will save all caches if cache name is nil +function globalcache.save(cachename) + if cachename then + globalcache.cache(cachename):save() + else + local caches = globalcache.caches() + if caches then + for _, cache in pairs(caches) do + cache:save() + end + end + end +end + -- clear the given cache, it will clear all caches if cache name is nil function globalcache.clear(cachename) if cachename then diff --git a/xmake/core/cache/localcache.lua b/xmake/core/cache/localcache.lua index 7ba00e7cc..3fd5d040f 100644 --- a/xmake/core/cache/localcache.lua +++ b/xmake/core/cache/localcache.lua @@ -172,6 +172,20 @@ function localcache.set3(cachename, key1, key2, key3, value) return localcache.cache(cachename):set3(key1, key2, key3, value) end +-- save the given cache, it will save all caches if cache name is nil +function localcache.save(cachename) + if cachename then + localcache.cache(cachename):save() + else + local caches = localcache.caches() + if caches then + for _, cache in pairs(caches) do + cache:save() + end + end + end +end + -- clear the given cache, it will clear all caches if cache name is nil function localcache.clear(cachename) if cachename then |
