Bugzilla – Attachment 174554 Details for
Bug 38454
Memory (L1) cache is not flushed before API requests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38454: [DO NOT PUSH] Add API route to showcase the bug
Bug-38454-DO-NOT-PUSH-Add-API-route-to-showcase-th.patch (text/plain), 1.55 KB, created by
Julian Maurice
on 2024-11-15 10:06:56 UTC
(
hide
)
Description:
Bug 38454: [DO NOT PUSH] Add API route to showcase the bug
Filename:
MIME Type:
Creator:
Julian Maurice
Created:
2024-11-15 10:06:56 UTC
Size:
1.55 KB
patch
obsolete
>From 732d1b8441e9f63607a4c624714671c6650bb8b3 Mon Sep 17 00:00:00 2001 >From: Julian Maurice <julian.maurice@biblibre.com> >Date: Fri, 15 Nov 2024 10:38:36 +0100 >Subject: [PATCH] Bug 38454: [DO NOT PUSH] Add API route to showcase the bug > >This route fetches a value from the memory cache, increment it, store it >in memory cache and return the incremented value. >If the memory cache was flushed before every request, the route should >always return "1". Instead it returns "1" at the first request, "2" at >the second request, and so on > >Test plan: >1. Start the REST API app: > `api/v1/app.pl daemon -l http://*:3000` >2. Use curl to request the app: > `curl http://localhost:3000/memlite-counter` >--- > Koha/REST/V1.pm | 12 ++++++++++++ > 1 file changed, 12 insertions(+) > >diff --git a/Koha/REST/V1.pm b/Koha/REST/V1.pm >index 52bd15697e..469e755da0 100644 >--- a/Koha/REST/V1.pm >+++ b/Koha/REST/V1.pm >@@ -160,6 +160,18 @@ sub startup { > $self->plugin('Koha::REST::Plugin::Responses'); > $self->plugin('Koha::REST::Plugin::Auth::IdP'); > $self->plugin( 'Mojolicious::Plugin::OAuth2' => $oauth_configuration ); >+ >+ $self->routes->get( >+ '/memlite-counter' => sub { >+ my $c = shift; >+ require Koha::Cache::Memory::Lite; >+ my $cache = Koha::Cache::Memory::Lite->get_instance(); >+ my $counter = $cache->get_from_cache('memlite-counter') // 0; >+ $counter = $counter + 1; >+ $cache->set_in_cache('memlite-counter', $counter); >+ $c->render( text => "$counter\n" ); >+ } >+ ); > } > > 1; >-- >2.39.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 38454
: 174554 |
174557
|
174760
|
174761
|
176673