3 init.remember <- function(){
5 if(exists("r") == FALSE){
6 if(file.exists(remember.file)){
7 if(!exists("remember.file.lock"))
9 lck <- lock(remember.file.lock, exclusive = FALSE)
10 r <<- readRDS(remember.file)
19 remember.file <<- "remembr.RDS"
20 init.file.lock <- function(){
21 remember.file.lock <<- paste0(remember.file,"_LOCK")
24 remember.prefix <<- ""
27 change.remember.file <- function(file,clear=FALSE){
29 remember.file <<- file
33 remember.file <<- file
38 set.remember.prefix <- function(prefix){
39 remember.prefix <<- prefix
42 load.if.exists <- function(){
43 if(file.exists(remember.file)){
44 if(!exists("remember.file.lock"))
46 lck <- lock(remember.file.lock, exclusive = FALSE)
47 r <<- readRDS(remember.file)
54 remember <- function(var,name,lock=T){
60 if(remember.prefix == ""){
63 if(is.null(r[[remember.prefix]])){
64 r[[remember.prefix]] <<- list()
66 r[[remember.prefix]][[name]] <<- var
72 save.remember <- function(lock=T){
73 if(!exists("remember.file.lock"))
76 lck <- lock(remember.file.lock, exclusive=TRUE)
77 saveRDS(r,file=remember.file)