GithubHelp home page GithubHelp logo

cachenv's Introduction

cachenv

Versatile memoizing cache for program invocations, with a virtualenv-like interface.

Note: this repo is still in early development; the README is aspirational.

Overview

cachenv is a lightweight tool that provides caching for your commands, scripts, and pipelines. In fact, any program that calls exec() can use cachenv.

It's like function memoization, but at the process boundary. This is useful in a variety of contexts, especially testing and rapid iteration.

The workflow mirrors that of virtualenv - you create an environment, activate it, and work within it.

Use Cases

  • Creating consistent, dependency-free testing environments
  • Rapidly iterating on scripts or notebooks that rely on external services or data processing
  • Efficiently constructing CLI pipelines that involve large inputs or expensive filters/aggregations
  • Eliminating redundant calls to metered APIs

Usage

Initialize and activate a new cachenv:

$ cachenv init .cachenv
Created activate script at .cachenv/activate

$ source .cachenv/activate

Enable memoization for ls:

(.cachenv) $ cachenv add ls
Command 'ls' added to memoized commands.
Refreshed symlink for ls

Enjoy(?) memoization for ls:

(.cachenv) $ ls
foo

(.cachenv) $ touch bar
(.cachenv) $ ls
foo

Try diff mode:

(.cachenv) $ cachenv diff ls
0a1
> bar

Features

Implemented Feature Description
Comprehensive Caching Captures stdout, stderr, and exit codes, providing a complete snapshot of a program's behavior given a particular input.
Selective Memoization Supports precise configuration to selectively enable caching based on program name, arguments, and/or input patterns.
Streaming Mode Supports caching at the line level, keyed by stdin.
File Awareness Can optionally distinguish cache entries based on the contents of files provided as arguments (e.g., for grep foo bar.txt, refresh the cache when the content of bar.txt changes).
Pipeline Compatibility Naturally integrates with command pipelines, allowing a mix of cached and live executions within complex command chains. Also includes optimizations which can effectively cache entire pipelines.
Diff Mode Can show changes in a program's behavior against a cached snapshot.
Cross-Environment Portability Enables cache sharing and reuse across different machines and operating systems.

cachenv's People

Contributors

aromatt avatar

Stargazers

Clayton Kehoe avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.