Skip to content

Commit

Permalink
update deps and devDeps
Browse files Browse the repository at this point in the history
  • Loading branch information
lagden committed Dec 14, 2023
1 parent 0a558d3 commit 12f2c7c
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 34 deletions.
8 changes: 6 additions & 2 deletions .editorconfig
Expand Up @@ -3,13 +3,17 @@ root = true
[*]
indent_style = tab
indent_size = 2
tab_width = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.{md,yml,json}]
[*.{md,yml,yaml,json,graphql}]
indent_style = space

[*.{md,yml}]
[*.{md,yml,yaml}]
trim_trailing_whitespace = false

[.registry-*]
insert_final_newline = false
9 changes: 7 additions & 2 deletions README.md
Expand Up @@ -18,7 +18,7 @@ Find data in cache
## Install

```
$ npm i -S @tadashi/find-in-cache
$ npm i @tadashi/find-in-cache
```

## Environment variable
Expand All @@ -28,7 +28,7 @@ variable | type | required | default | descriptio
REDIS | string | no | 127.0.0.1:6379 | Addresses to connect
REDIS_PWD | string | no | - | Redis password
CACHE_REDIS_PREFIX | string | no | lib | Key prefix
CACHE_REDIS_NAMESPACE | string | no | find\_in\_cache | Avoid conflicts between caches
CACHE_REDIS_NAMESPACE | string | no | find-in-cache | Avoid conflicts between caches
CACHE_REDIS_DB | number | no | 0 | Number of database
CLEAR_CACHE_FIRST_RUN | boolean | no | true | Clear cache when app is started

Expand Down Expand Up @@ -76,6 +76,11 @@ await cache.clear()
```


## Donate ❤️

BTC: bc1q7famhuj5f25n6qvlm3sssnymk2qpxrfwpyq7g4


## License

MIT © [Thiago Lagden](https://github.com/lagden)
12 changes: 5 additions & 7 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "@tadashi/find-in-cache",
"version": "2.4.0",
"version": "2.4.1",
"description": "Find data in cache",
"keywords": [
"cache",
Expand Down Expand Up @@ -30,17 +30,15 @@
"scripts": {
"eslint": "eslint --config .eslintrc.yml --ext .js --ignore-path .gitignore .",
"pretest": "npm run eslint",
"docker:rm": "docker kill redis-test; docker rm redis-test",
"docker": "docker run -p 6379:6379 --name redis-test -d redis:latest",
"docker:rm": "docker kill find-cache-redis-test; docker rm find-cache-redis-test",
"docker": "docker run -p 6379:6379 --name find-cache-redis-test -d redis:latest",
"test": "c8 --reporter=text --reporter=text-summary --reporter=lcovonly --reporter=cobertura node --test test/*.spec.js"
},
"dependencies": {
"@tadashi/common": "4.2.0",
"@tadashi/cache-redis": "6.4.1",
"@tadashi/common": "4.2.1",
"@tadashi/hash": "3.0.1"
},
"peerDependencies": {
"@tadashi/cache-redis": "6.4.0"
},
"devDependencies": {
"c8": "8.0.1",
"eslint": "8.55.0",
Expand Down
24 changes: 12 additions & 12 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src/find-in-cache.js
Expand Up @@ -26,8 +26,8 @@ export function caching(key, value, _ttl) {
const cacheName = hash(key, {alg: 'sha1', encoding: 'hex'})
let args = []

const ttl = Number(_ttl)
if (ttl && Number.isNaN(ttl) === false && ttl > 0) {
const ttl = globalThis.Number(_ttl)
if (ttl && globalThis.Number.isInteger(ttl) && ttl > 0) {
args = ['EX', ttl]
}

Expand Down
13 changes: 4 additions & 9 deletions test/find-in-cache.spec.js
@@ -1,19 +1,13 @@
#!/usr/bin/env node

import {test, before, after} from 'node:test'
import {test, after} from 'node:test'
import assert from 'node:assert/strict'
import {
find,
caching,
cache,
} from '../src/find-in-cache.js'

before(async () => {
await cache.clear()
})

after(() => {
process.exit(0)
cache.redis.disconnect(false)
})

// Caching data forever
Expand Down Expand Up @@ -48,6 +42,7 @@ test('finding - Third Run', async () => {

// // Find Object key
// test('finding - Object key', async () => {
// await caching({a: 123}, 'Apenas um show')
// const res = await find({a: 123})
// assert.equal(res, undefined)
// assert.equal(res, 'Apenas um show')
// })

0 comments on commit 12f2c7c

Please sign in to comment.