# redis-hogan-cache

> A Redis hogan.js cache

Latest version **2.0.0** (published 2026-10-10) · ISC license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install redis-hogan-cache
pnpm add redis-hogan-cache
yarn add redis-hogan-cache
bun add redis-hogan-cache
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2026-10-10 |
| First published | 2016-05-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=20 |
| Dependencies | 2 |
| Unpacked size | 6.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Oliver Grüttner |
| Maintainers | defkil |
| Keywords | redis, cache, hogan.js, http, express, cache, fast |

## Links

- npm: https://www.npmjs.com/package/redis-hogan-cache
- Repository: https://github.com/Defkil/rhc
- Homepage: https://github.com/Defkil/rhc#readme
- Issues: https://github.com/Defkil/rhc/issues
- npm.io page: https://npm.io/package/redis-hogan-cache

## Dependencies (2)

- [redis](https://npm.io/package/redis.md) ^6.3.0
- [hogan.js](https://npm.io/package/hogan.js.md) ^3.0.2

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2026-10-10
- 1.0.3 — 2026-10-10
- 1.0.2 — 2016-05-18
- 1.0.1 — 2016-05-18
- 1.0.0 — 2016-05-18

## README

# Redis-hogan-cache

> **Deprecated:** this package is no longer developed, and hogan.js has had no release since 2014.
> For new projects use a maintained template engine such as [Handlebars](https://handlebarsjs.com/)
> (Mustache-compatible, for Express via [express-handlebars](https://www.npmjs.com/package/express-handlebars)),
> [Eta](https://eta.js.org/), [LiquidJS](https://liquidjs.com/) or [EJS](https://ejs.co/), and let Express keep
> compiled views in memory (`view cache`, on by default in production).
>
> Versions before 1.0.3 stored compiled templates in Redis and ran them with `eval`: anyone who could write to
> that Redis could run code in your app. Update to 1.0.3 at least. 2.x needs Node 20 and a node-redis client of
> version 4 or later; 1.0.3 keeps the callback client of node-redis 3.

Use hogan.js with a cache in redis. You can use a already defined redis client

Require Redis-hogan-cache
```javascript
var rhc = require('redis-hogan-cache')
```

---

Create a new RHC instance
```javascript
//with a new redis client
rhc({prefix:'rhc:', expire:'10000', redis:{hostname:'localhost', password:'', port:6379, db:0}})

//with an already created and connected redis client (node-redis 4 or later)
//redisClient = await redis.createClient().connect()
rhc({prefix:'rhc:', expire:'10000', client:redisClient})
```

---

```javascript
rhc({options})
/**
 * @param {Object} options                Settings to use to RHC
 * @param {Object} options.client         A connected node-redis client, version 4 or later
 * @param {Object} options.redis          [Optional] Redis client information, if options.client not used 
 * @param {Object} options.redis.hostname [Optional] Redis server hostname
 * @param {Object} options.redis.password [Optional] Redis server password
 * @param {Object} options.redis.port     [Optional] Redis server port
 * @param {Object} options.redis.db       [Optional] Redis server database; dafault: `1`
 * @param {string} options.prefix         [Optional] A prefix to append to key names in Redis; default: `rhc:`
 * @param {int}    options.expire         [Optional] Template expire in seconds or `never`; default: `10`
 */
```

---

With Express

```javascript
app.set('view cache', false)//disable express cache
app.set('view engine', 'html')//setup html engine
app.engine('html',rhc.render)//define rhc as render engine
app.get('/', function (req, res) {
    res.render('index.html', {message:'A awesome Site', expire:100})
})
```

Just on a http server
```javascript
//create a new rhc instance
rhc({prefix:'rhc:', redis:{hostname:'localhost', password:'', port:6379, db:0}})
var server = http.createServer(function(req, res){
    //use rhc.render()
    rhc.render('../views/index.html', {message:'A awesome Site', expire:100}, function(err, html){
      res.end(html) 
    })
})
```

---
_Source: https://npm.io/package/redis-hogan-cache · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
