shell_gpt icon indicating copy to clipboard operation
shell_gpt copied to clipboard

Implement caching

Open TheR1D opened this issue 3 years ago • 0 comments

In some cases, we may need to run sgpt twice with the same prompt in order to pipe the output somwhere else. For example:

sgpt --code "implement merge sort algorithm using C language"


#include <stdio.h>

void merge(int arr[], int l, int m, int r)
{
    int i, j, k;
    int n1 = m - l + 1;
    int n2 =  r - m;
...

The output in this case can be quite large, and it would be helpful to use less to view it:

sgpt --code "implement merge sort algorithm using C language" | less

But we would spent +1 query and couple seconds of waiting just to get same (not always) response. It would be useful to implement some form of caching for the last n outputs, as well as a way to invalidate the cache (for example, by using --cache and --no-cache arguments)."

TheR1D avatar Feb 15 '23 23:02 TheR1D