Javier Gutierrez
Javier Gutierrez

Reputation: 559

PlayFramework shared Cache problem

Hi I'm creating subdirectories dynamically using routes, something like that

GET     /event/{nick}                           EventPageController.show

and I use it with something like that

example.com/event/congres2011
example/com/event/symposiumXI

then I get the first event in database and save in a key Cache

public static void show(String nick) {
        Event event = Event.find("byNick", nick).first();
        if (event == null) {
            redirect("/");
        }
        Cache.add("event", event);
        render(event);
    }

but when I request for the second (example/com/event/symposiumXI), the show method use the same key to save the new request event, for this reason the first event lost context. Please how can I controll it?, or maybe can I restringe to use onlyone event at same time...?

Upvotes: 0

Views: 347

Answers (1)

sojin
sojin

Reputation: 4694

Since you are using the static key "event", it will be replaced. You might want to make it more context-aware by making the key something like nick + "event".

Upvotes: 2

Related Questions