Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deleting links #15

Open
dragonhuntr opened this issue Aug 20, 2021 · 4 comments
Open

deleting links #15

dragonhuntr opened this issue Aug 20, 2021 · 4 comments

Comments

@dragonhuntr
Copy link

how to delete links after 24 hours?
如何24小时后删啊

@nICEnnnnnnnLee
Copy link

参考https://developers.cloudflare.com/workers/runtime-apis/kv#creating-expiring-keys
将原代码

return await LINKS.put(random_key, URL),random_key

改为

return await LINKS.put(random_key, URL, {expirationTtl: 60*60*24}),random_key 

@bobotoy
Copy link

bobotoy commented Aug 27, 2021

参考https://developers.cloudflare.com/workers/runtime-apis/kv#creating-expiring-keys
将原代码

return await LINKS.put(random_key, URL),random_key

改为

return await LINKS.put(random_key, URL, {expirationTtl: 60*60*24}),random_key 

参考https://developers.cloudflare.com/workers/runtime-apis/kv#creating-expiring-keys
将原代码

return await LINKS.put(random_key, URL),random_key

改为

return await LINKS.put(random_key, URL, {expirationTtl: 60*60*24}),random_key 

是否可以变成阅后即焚,链接点击后就失效?

@nICEnnnnnnnLee
Copy link

是否可以变成阅后即焚,链接点击后就失效?

在确认获得url后返回302之前,删除这条KV即可。

const value = await LINKS.get(path)
console.log(value)
const location = value
if (location) {
return Response.redirect(location, 302)
}

即在上述L100行后的判断里面添加

await LINKS.delete(path)

@fuzzdb
Copy link

fuzzdb commented Nov 5, 2021

是否可以变成阅后即焚,链接点击后就失效?

在确认获得url后返回302之前,删除这条KV即可。

const value = await LINKS.get(path)
console.log(value)
const location = value
if (location) {
return Response.redirect(location, 302)
}

即在上述L100行后的判断里面添加

await LINKS.delete(path)
 if (location) { 
   await LINKS.delete(path)
   return Response.redirect(location, 302)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants