Skip to content

Commit

Permalink
v10.13.0: adds cacheKey
Browse files Browse the repository at this point in the history
  • Loading branch information
10xSebastian committed May 17, 2023
1 parent ffc4102 commit 3825616
Show file tree
Hide file tree
Showing 11 changed files with 19 additions and 17 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,8 @@ The number passed to `cache` is the amount of ms the cached result should stay v

If nothing or `0` is passed to `cache`, the request is not cached.

You can set a `cacheKey` manually, otherwise it will use `[blockchain, address, method, params, block]` as cache key.

#### resetCache

Make sure you reset cache between your tests to prevent cached states affect other tests:
Expand Down
4 changes: 2 additions & 2 deletions dist/esm/index.evm.js
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,11 @@ var parseUrl = (url) => {
const request = async function (url, options) {

const { blockchain, address, method } = parseUrl(url);
const { api, params, cache: cache$1, block, timeout, strategy } = (typeof(url) == 'object' ? url : options) || {};
const { api, params, cache: cache$1, block, timeout, strategy, cacheKey } = (typeof(url) == 'object' ? url : options) || {};

return await cache({
expires: cache$1 || 0,
key: [blockchain, address, method, params, block],
key: cacheKey || [blockchain, address, method, params, block],
call: async()=>{
if(supported.evm.includes(blockchain)) {

Expand Down
4 changes: 2 additions & 2 deletions dist/esm/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -895,11 +895,11 @@ var parseUrl = (url) => {
const request = async function (url, options) {

const { blockchain, address, method } = parseUrl(url);
const { api, params, cache: cache$1, block, timeout, strategy } = (typeof(url) == 'object' ? url : options) || {};
const { api, params, cache: cache$1, block, timeout, strategy, cacheKey } = (typeof(url) == 'object' ? url : options) || {};

return await cache({
expires: cache$1 || 0,
key: [blockchain, address, method, params, block],
key: cacheKey || [blockchain, address, method, params, block],
call: async()=>{
if(supported.evm.includes(blockchain)) {

Expand Down
4 changes: 2 additions & 2 deletions dist/esm/index.solana.js
Original file line number Diff line number Diff line change
Expand Up @@ -590,11 +590,11 @@ var parseUrl = (url) => {
const request = async function (url, options) {

const { blockchain, address, method } = parseUrl(url);
const { api, params, cache: cache$1, block, timeout, strategy } = (typeof(url) == 'object' ? url : options) || {};
const { api, params, cache: cache$1, block, timeout, strategy, cacheKey } = (typeof(url) == 'object' ? url : options) || {};

return await cache({
expires: cache$1 || 0,
key: [blockchain, address, method, params, block],
key: cacheKey || [blockchain, address, method, params, block],
call: async()=>{
if(supported.evm.includes(blockchain)) ; else if(supported.solana.includes(blockchain)) {

Expand Down
4 changes: 2 additions & 2 deletions dist/umd/index.evm.js
Original file line number Diff line number Diff line change
Expand Up @@ -546,11 +546,11 @@
const request = async function (url, options) {

const { blockchain, address, method } = parseUrl(url);
const { api, params, cache: cache$1, block, timeout, strategy } = (typeof(url) == 'object' ? url : options) || {};
const { api, params, cache: cache$1, block, timeout, strategy, cacheKey } = (typeof(url) == 'object' ? url : options) || {};

return await cache({
expires: cache$1 || 0,
key: [blockchain, address, method, params, block],
key: cacheKey || [blockchain, address, method, params, block],
call: async()=>{
if(supported.evm.includes(blockchain)) {

Expand Down
4 changes: 2 additions & 2 deletions dist/umd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -901,11 +901,11 @@
const request = async function (url, options) {

const { blockchain, address, method } = parseUrl(url);
const { api, params, cache: cache$1, block, timeout, strategy } = (typeof(url) == 'object' ? url : options) || {};
const { api, params, cache: cache$1, block, timeout, strategy, cacheKey } = (typeof(url) == 'object' ? url : options) || {};

return await cache({
expires: cache$1 || 0,
key: [blockchain, address, method, params, block],
key: cacheKey || [blockchain, address, method, params, block],
call: async()=>{
if(supported.evm.includes(blockchain)) {

Expand Down
4 changes: 2 additions & 2 deletions dist/umd/index.solana.js
Original file line number Diff line number Diff line change
Expand Up @@ -596,11 +596,11 @@
const request = async function (url, options) {

const { blockchain, address, method } = parseUrl(url);
const { api, params, cache: cache$1, block, timeout, strategy } = (typeof(url) == 'object' ? url : options) || {};
const { api, params, cache: cache$1, block, timeout, strategy, cacheKey } = (typeof(url) == 'object' ? url : options) || {};

return await cache({
expires: cache$1 || 0,
key: [blockchain, address, method, params, block],
key: cacheKey || [blockchain, address, method, params, block],
call: async()=>{
if(supported.evm.includes(blockchain)) ; else if(supported.solana.includes(blockchain)) {

Expand Down
2 changes: 1 addition & 1 deletion package.evm.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-client-evm",
"moduleName": "Web3Client",
"version": "10.12.4",
"version": "10.13.0",
"description": "A web3 client to fetch blockchain data just like you are used to with HTTP clients.",
"main": "dist/umd/index.evm.js",
"module": "dist/esm/index.evm.js",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-client",
"moduleName": "Web3Client",
"version": "10.12.4",
"version": "10.13.0",
"description": "A web3 client to fetch blockchain data just like you are used to with HTTP clients.",
"main": "dist/umd/index.js",
"module": "dist/esm/index.js",
Expand Down
2 changes: 1 addition & 1 deletion package.solana.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@depay/web3-client-solana",
"moduleName": "Web3Client",
"version": "10.12.4",
"version": "10.13.0",
"description": "A web3 client to fetch blockchain data just like you are used to with HTTP clients.",
"main": "dist/umd/index.solana.js",
"module": "dist/esm/index.solana.js",
Expand Down
4 changes: 2 additions & 2 deletions src/request.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ import { supported } from './blockchains'
const request = async function (url, options) {

const { blockchain, address, method } = parseUrl(url)
const { api, params, cache, block, timeout, strategy } = (typeof(url) == 'object' ? url : options) || {}
const { api, params, cache, block, timeout, strategy, cacheKey } = (typeof(url) == 'object' ? url : options) || {}

return await cacheRequest({
expires: cache || 0,
key: [blockchain, address, method, params, block],
key: cacheKey || [blockchain, address, method, params, block],
call: async()=>{
if(supported.evm.includes(blockchain)) {

Expand Down

0 comments on commit 3825616

Please sign in to comment.