
Security News
ESLint Adds Official Support for Linting HTML
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
FIFO Cache is fast hash-like fixed size cache class with FIFO functionality which removes oldest or less accessed records based on implicit heap.
Cache allows track both hits and puts and remove items from cache
according these statistics. They are turned off by default, but can be
turned on by setting #factor
(or :factor
in costructor) to another
value than 0
.
Handicap factor is multiplier of the minimal hits count of all items in the cache. It's important set it in some cases.
If tracking is turned on and no handicap factor is explicitly set, handicap 1 is assigned to new items. It's safe, but not very acceptable because cache will become static after filling. So it's necessary (or at least higly reasonable) to set priority weighting factor to number higher than 1 according dynamics of your application.
Usage is simple (examples here are for demonstration purposes written without factor set):
require "fifocache"
cache = Fifocache::new(3, :puts => true) # or 300000, od sure :-)
cache[:alfa] = 'alfa'
cache[:beta] = 'beta'
cache[:gama] = 'gama'
cache[:delta] = 'delta' # in this moment, :alfa is removed
But multiple addings are tracked, so subsequent call:
cache[:beta] = 'beta' # :beta, :gama, :delta in cache
cache[:alfa] = 'alfa' # :beta, :delta, :alfa in cache
…will cause :gama
will be removed, not :beta
because :beta
is
fresher now. If hits tracking is turned on:
cache.hits = true # you can do it in constructor too
puts cache[:delta] # cache hit
cache[:gama] = 'gama' # :beta, :delta, :gama in cache
…because :beta
has been put-in two times, :delta
has been hit
recently, so :alfa
is less accessed row and has been removed. In case
of hits tracking turned off, :delta
would be removed of sure and
:alfa
kept.
Changing size of existing cache is possible although reducing the size is generally rather slow because of necessity to remove all redundant "oldest" rows.
Copyright © 2010 – 2015 Martin Poljak.
See LICENSE.txt
for further details.
FAQs
Unknown package
We found that fifo-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.
Security News
ESLint now supports HTML linting with 48 new rules, expanding its language plugin system to cover more of the modern web development stack.
Security News
CISA is discontinuing official RSS support for KEV and cybersecurity alerts, shifting updates to email and social media, disrupting automation workflows.
Security News
The MCP community is launching an official registry to standardize AI tool discovery and let agents dynamically find and install MCP servers.