Skip to content

Commit

Permalink
feat: adding clear content cache form to clear soon to come bentocach…
Browse files Browse the repository at this point in the history
…e items
  • Loading branch information
tomgobich committed Apr 28, 2024
1 parent fb35d09 commit c5bbc95
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
11 changes: 11 additions & 0 deletions app/Controllers/Http/DashboardController.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Redis from '@ioc:Adonis/Addons/Redis'
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
import Collection from 'App/Models/Collection'
import Post from 'App/Models/Post'
Expand All @@ -12,4 +13,14 @@ export default class DashboardController {

return view.render('studio/index', { postCount, postSeconds, seriesCount, topicCount })
}

public async clearBentoCache({ response, session }: HttpContextContract) {
const keys = await Redis.keys('bentocache:*')

await Redis.del(keys)

session.flash('success', 'Bentocache items have been cleared')

return response.redirect().back()
}
}
1 change: 0 additions & 1 deletion resources/views/components/header/studio.edge
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
Nav('Collections', route('studio.collections.index'), 'CollectionPolicy.viewList'),
Nav('Taxonomies', route('studio.taxonomies.index'), 'TaxonomyPolicy.viewList'),
Nav('Comments', route('studio.comments.index'), 'StudioPolicy.viewComments'),
Nav('Settings', 'https://adocasts.com/users/settings', 'StudioPolicy.viewSettings'),
Nav('Users', route('studio.users.index'), 'StudioPolicy.viewUsers'),
Nav('Roles', route('studio.users.roles.index'), 'StudioPolicy.adminOnly'),
Nav('Plans', route('studio.plans.index'), 'StudioPolicy.adminOnly')
Expand Down
7 changes: 7 additions & 0 deletions resources/views/studio/index.edge
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@

@section('heading')
@studio.heading({ heading: 'Welcome to the Adocasts Studio' })
<form method="POST" action="{{ route('studio.dashboard.clearBentoCache', {}, { qs: { _method: 'DELETE' } })}}">
{{ csrfField() }}

@button({ type: 'submit', size: 'sm' })
Clear Content Cache
@end
</form>
@end
@endsection

Expand Down
1 change: 1 addition & 0 deletions start/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Route.get('/img/*', 'AssetsController.show').where('path', /.*/).as('img')
Route.group(() => {

Route.get('/', 'DashboardController.index').as('dashboard.index')
Route.delete('/cache/bento', 'DashboardController.clearBentoCache').as('dashboard.clearBentoCache').middleware(['role:admin'])

Route.group(() => {

Expand Down

0 comments on commit c5bbc95

Please sign in to comment.