GithubHelp home page GithubHelp logo

cacher's Introduction

cacher codecov.ioBuild Status

In memory caches for R. Currently implements LRU cache with size parameter.

Create a cache...

cache <- LRUcache("150mb")  # cache with 150mb of size
cache2 <- LRUcache("1GB")   # cache with 1GB of size
cache3 <- LRUcache(3)       # cache that can hold three items of any size (that fits in RAM)

Then use it...

cache3$set("key", "this is your value")  # set a value at a particular key...
cache3$get("key")                        # ...and get that value back!
[1] "this is your value"

cache3$peek("key")                       # doesn't alter the key's timestamp
[1] "this is your value"

cache3$exists("key")                     # ...see if your key exists
[1] TRUE

cache3$set("key2", "hi")                 # but if you go over your size...
cache3$set("key3", "hello")
cache3$set("key4", "yo")
cache3$exists("key")                     # ...the oldest key will automatically go away.
[1] FALSE                                # oldness is determined on when the key was most
                                         # recently accessed, not when it was set.

cache3$exists("key4")
[1] TRUE
cache3$forget("key4")                    # you can also explicitly forget a certain key.
cache3$exists("key4")
[1] FALSE

Installation

Install with devtools.

install.packages("devtools")
library(devtools)
install_github("kirillseva/cacher")

cacher's People

Contributors

abelcastilloavant avatar captainpete avatar elainexmas avatar kirillseva avatar peterhurford avatar robertzk avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cacher's Issues

Installation Error

Trying to install this, and I get the error:

"Error : package 'cacher' is not installed for 'arch = i386'
Error: loading failed"

Can you clarify what this means?

New caches still have access to old data

cache <- cacher::LRUcache("1000B")
cache$set("test", "test value")
cache$exists("test")
[1] TRUE
cache$get("test")
[1] "test value"

new_cache <- cacher::LRUcache("1000B")
# Without setting anything, it exists in the new cache
new_cache$exists("test")
[1] TRUE
new_cache$get("test")
[1] "test value"

# It even still exists in a new cache where it is too large to actually be stored there.
tiny_cache <- cacher::LRUcache("1B")
tiny_cache$get("test")
[1] "test value"
tiny_cache$set("test", "test")
Warning message:
'test' is too large (96B) to fit in the cache (1B) and will not be cached. Consider creating a larger cache.

MIT License

Hello

Was wondering if we could get an MIT License added to this Repo. Avant is looking to fork this repo and we'd like to have this added before doing so.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.