Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

easycache

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

easycache

  • 0.0.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

EasyCache

Gem Version License Lint Tests Build

Maybe not the best caching system, but its a caching system :)

EasyCache is an in-memory cache system for Ruby designed for situations where you don't want to set up Redis or Memcached but still need a simple solution for caching key-value data in the process memory.

Install

gem install easycache

Usage

To use EasyCache in your Ruby project, require the library and include it in your code:

require 'easycache'

cache = EasyCache.new

Storing data

key = "my_key"
cache_ttl = 3600
store_in_mem = true
data = cache.fetch(cache_key, cache_ttl, store_in_mem) do
    my_http_get
end

Now data is in-mem for the next 3600 second (store_in_mem variable is important for storing data first time).

Getting data

If i want to get the data stored in mem i do

data = cache.fetch("my_key")

or i can also re-call the same function

data = cache.fetch("my_key", cache_ttl, store_in_mem) do
    my_http_get
end

because the data is already cached, so it will not call the block, it will return the cached data instead.

This will output the cached data, remember that cached data is stored in mem for only 3600 seconds

Examples

You can search for examples in examples folder for caching http requests and responses using EasyCache

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/malvads/easycache .

FAQs

Package last updated on 29 Feb 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