[rkward-cvs] rkward/rkward/rbackend/rpackages/rkward/R internal.R, 1.28, 1.29
Thomas Friedrichsmeier
tfry at users.sourceforge.net
Sun Sep 10 20:47:31 UTC 2006
Update of /cvsroot/rkward/rkward/rkward/rbackend/rpackages/rkward/R
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv1914/rbackend/rpackages/rkward/R
Modified Files:
internal.R
Log Message:
Add simple caching for available.packages ()
Index: internal.R
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rpackages/rkward/R/internal.R,v
retrieving revision 1.28
retrieving revision 1.29
diff -C2 -d -r1.28 -r1.29
*** internal.R 21 Jun 2006 16:57:40 -0000 1.28
--- internal.R 10 Sep 2006 20:47:28 -0000 1.29
***************
*** 107,113 ****
}
".rk.get.available.packages" <- function () {
! x <- available.packages ()
return (c (as.vector (x[,1]), as.vector (x[,2])))
}
--- 107,136 ----
}
+ # This function works like available.packages (with no arguments), but does simple caching of the result, and of course uses a cache if available. Cache is only used, if it is less than 1 hour old, and options("repos") is unchanged.
+ ".rk.cached.available.packages" <- function () {
+ x <- NULL
+ if (exists (".rk.available.packages.cache")) {
+ if (.rk.available.packages.cache$timestamp > (Sys.time () - 3600)) {
+ if (all (.rk.available.packages.cache$repos$repos == options ("repos")$repos)) {
+ x <- .rk.available.packages.cache$cache
+ }
+ }
+ }
+
+ if (is.null(x)) {
+ x <- available.packages()
+ .rk.available.packages.cache <<- list (cache = x, timestamp = Sys.time (), repos = options ("repos"))
+ }
+
+ return (x)
+ }
+
+ ".rk.get.old.packages" <- function () {
+ x <- old.packages (available=.rk.cached.available.packages ())
+ return (as.vector (c (x[,"Package"], x[,"LibPath"], x[,"Installed"], x[,"ReposVer"])))
+ }
".rk.get.available.packages" <- function () {
! x <- .rk.cached.available.packages ()
return (c (as.vector (x[,1]), as.vector (x[,2])))
}
More information about the rkward-tracker
mailing list