New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

zache

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

zache

  • 0.13.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

In Memory Cache for Ruby

EO principles respected here DevOps By Rultor.com We recommend RubyMine

rake Gem Version Maintainability Yard Docs License Test Coverage Hits-of-Code

It's a simple Ruby gem for in-memory cache. Read this blog post to understand what Zache is for.

First, install it:

gem install zache

Then, use it like this

require 'zache'
zache = Zache.new
# Expires in 5 minutes
v = zache.get(:count, lifetime: 5 * 60) { expensive() }

By default Zache is thread-safe. It locks the entire cache on each get call. You turn that off by using sync argument:

zache = Zache.new(sync: false)
v = zache.get(:count) { expensive() }

You may use "dirty" mode, which will return you an expired value, while calculation is waiting. Say, you have something in the cache, but it's expired. Then, you call get with a long running block. The thread waits, while another one calls get again. That second thread won't wait, but will receive what's left in the cache. This is a very convenient mode for situations when you don't really care about data accuracy, but performance is an issue.

The entire API is documented here (there are many other convenient methods).

That's it.

How to contribute

Read these guidelines. Make sure you build is green before you contribute your pull request. You will need to have Ruby 2.3+ and Bundler installed. Then:

bundle update
bundle exec rake

If it's clean and you don't see any error messages, submit your pull request.

FAQs

Package last updated on 18 Jul 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc