Skip to content

Commit

Permalink
feat: add a pinata implementation without cache (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
neilcampbell authored Jan 5, 2024
1 parent 561af6b commit 5cf4748
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/ipfs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,3 +296,24 @@ export class PinataStorageWithCache implements IPFS {
}
}
}

class NoOpCache implements ObjectCache {
getAndCache<T>(
_cacheKey: string,
generator: (existing: T | undefined) => Promise<T>,
_staleAfterSeconds?: number | undefined,
_returnStaleResult?: boolean | undefined,
_isBinary?: boolean | undefined,
): Promise<T> {
return generator(undefined)
}
put<T>(_cacheKey: string, _data: T): Promise<void> {
return Promise.resolve()
}
}

export class PinataStorage extends PinataStorageWithCache {
constructor(pinataToken: string) {
super(pinataToken, new NoOpCache())
}
}

0 comments on commit 5cf4748

Please sign in to comment.