Local metadata link commit at 2025-06-06 15:40:57 — file:///home/mrhavens/git-local-repos/git-sigil.git
This commit is contained in:
commit
b548318725
134 changed files with 15789 additions and 0 deletions
17
src/utils/views/ioredis.ts
Normal file
17
src/utils/views/ioredis.ts
Normal file
|
@ -0,0 +1,17 @@
|
|||
import Redis from 'ioredis'
|
||||
const client = new Redis(import.meta.env.REDIS_URI)
|
||||
|
||||
export const getViewsBySlug = async (slug: string) => {
|
||||
if (slug) {
|
||||
const prevValue = await client.get(slug);
|
||||
let newValue = 1;
|
||||
if (prevValue) {
|
||||
newValue = parseInt(`${prevValue}`) + 1;
|
||||
await client.set(slug, newValue);
|
||||
} else {
|
||||
await client.set(slug, 1);
|
||||
}
|
||||
return newValue;
|
||||
}
|
||||
return 0;
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue