lesson_storage: Internal cache for storing lesson objects

Description Usage Arguments Details Examples

Description

A storage cache for pegboard::Lesson objects that works across the functions while sandpaper is working.

Usage

1
2
3
4
5

Arguments

path

a path to the current lesson

Details

this_lesson() will return a pegboard::Lesson object if it has previously been stored. There are three values that are cached:

The function this_lesson() first checks if .this_diff is different than the output of gert::git_diff_patch() and then check if there are any changes to gert::git_status(). If there are no differences or the values are not previously cached, the lesson is loaded into memory.

If there have been no changes git is aware of, the lesson remains the same.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
tmp <- tempfile()
create_lesson(tmp, open = FALSE)
# Read the lesson into cache
system.time(sandpaper:::this_lesson(tmp)) 
system.time(sandpaper:::this_lesson(tmp)) # less time to read in once cached
l <- sandpaper:::this_lesson(tmp)
l
# clear the cache
sandpaper:::clear_this_lesson()
system.time(sandpaper:::this_lesson(tmp)) # have to re-read the lesson
system.time(sandpaper:::this_lesson(tmp)) 
unlink(tmp)

zkamvar/sandpaper documentation built on Nov. 25, 2021, 1:16 p.m.