Java app can't access cache entries written by other processes

11 views
Skip to first unread message

Mike Stoddart

unread,
Apr 6, 2016, 3:25:25 PM4/6/16
to xmemcached
I'm testing a simple application using xmemcached that will read cache values set by a Python application. For whatever reason, my Java app can't read any entries written by the Python app. The Java app can read entries that it writes, but nothing written by another process. This is confusing me - does this ring any bells with anyone?










                        XMemcachedClientBuilder builder = new XMemcachedClientBuilder(


                                        AddrUtil.getAddresses(MEMCACHED_HOSTNAME + ":"


                                                        + MEMCACHED_PORT));


                        builder.setCommandFactory(new BinaryCommandFactory());


                        client = builder.build();




                        System.out.println("Servers: " + client.getAvailableServers());




                        String result;


                        try {


                                result = client.get("group_perms");


                                if (result != null) {


                                        System.out.println("Result: " + result.toString());


                                } else {


                                        System.out.println("No result");


                                }




                                client.set("age", 0, "44");


                                System.out.println("Age: " + client.get("age"));




                        } catch (TimeoutException e) {


                                // TODO Auto-generated catch block


                                e.printStackTrace();


                        } catch (InterruptedException e) {


                                // TODO Auto-generated catch block


                                e.printStackTrace();


                        } catch (MemcachedException e) {


                                // TODO Auto-generated catch block


                                e.printStackTrace();


                        }



Thanks

Mike Stoddart

unread,
Apr 6, 2016, 3:25:49 PM4/6/16
to xmemcached
Apologies for the weird formatting - I can't get it to format properly.

Mike Stoddart

unread,
May 17, 2016, 10:55:01 AM5/17/16
to xmemcached
I didn't realize that Django was prefixing all cache keys with a version number, so a key of:

"cache_key"

Is actually written to Memcached by Django as:

":1:cache_key"

Where the ":1:" is a version number specified in the Django settings.

Oops.


On Wednesday, 6 April 2016 15:25:25 UTC-4, Mike Stoddart wrote:
Reply all
Reply to author
Forward
0 new messages