https://github.com/kirillseva/cacher
In memory cache interface for R
https://github.com/kirillseva/cacher
Last synced: 5 months ago
JSON representation
In memory cache interface for R
- Host: GitHub
- URL: https://github.com/kirillseva/cacher
- Owner: kirillseva
- Created: 2015-09-30T21:55:18.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2018-03-05T17:21:10.000Z (about 7 years ago)
- Last Synced: 2024-08-13T07:13:55.154Z (8 months ago)
- Language: R
- Homepage:
- Size: 38.1 KB
- Stars: 4
- Watchers: 2
- Forks: 4
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- jimsghstars - kirillseva/cacher - In memory cache interface for R (R)
README
# cacher [](http://codecov.io/github/kirillseva/cacher?branch=master)[](https://travis-ci.org/kirillseva/cacher)
In memory caches for R. Currently implements LRU cache with size parameter.
Create a cache...
```R
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...
```R
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] TRUEcache3$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](https://github.com/hadley/devtools).
```R
install.packages("devtools")
library(devtools)
install_github("kirillseva/cacher")
```