
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
EasyCache is a way to easily cache method calls to a readable YAML file.
Internally it uses the gemmy library I made.
Specifically, the PersistedHash (which syncs a hash's state to YAML file) is
extended with a get_or_set(key, &blk)
method where the block result gets cached as key
.
The return value of get_or_set
is the block result. So it can easily be placed as a wrapper
around any synchronous method:
require 'easy_cache'
# The ~/gemmy path will be automatically created
# However the cache path can be overridden with:
# ENV["GEMMY_CACHE_PATH"]
my_method_cad(arg)
my_method_cache.get_or_set(arg) do
"#{arg} result is saved"
end
end
def my_method(arg)
my_method_cache.get_or_set(arg) do
"#{arg} result is saved"
end
end
There are other methods in the API, too.
#clear
#set_state(hash)
#get(*nested_keys)
#set(*nested_keys, val)
#data
(the entire state)Note that []
and []=
only interact with the in-memory hash. They don't touch the YAML file.
FAQs
Unknown package
We found that easy_cache demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.