this.dao = dao;
//read_str = "Cached READ for " + dao.table();
// dirty_str = "Cache DIRTY on " + dao.table();
- if(dao instanceof CassDAOImpl) {
+ if (dao instanceof CassDAOImpl) {
((CassDAOImpl<?,?>)dao).cache = this;
}
}
public static String keyFromObjs(Object ... objs) {
String key;
- if(objs.length==1 && objs[0] instanceof String) {
+ if (objs.length==1 && objs[0] instanceof String) {
key = (String)objs[0];
} else {
StringBuilder sb = new StringBuilder();
boolean first = true;
- for(Object o : objs) {
- if(o!=null) {
- if(first) {
+ for (Object o : objs) {
+ if (o!=null) {
+ if (first) {
first =false;
} else {
sb.append('|');
public Result<DATA> create(TRANS trans, DATA data) {
Result<DATA> d = dao.create(trans,data);
- if(d.status==Status.OK) {
+ if (d.status==Status.OK) {
add(d.value);
} else {
trans.error().log(d.errorString());
@Override
public final Result<List<DATA>> get() {
return call();
-// if(result.isOKhasData()) { // Note, given above logic, could exist, but stale
+// if (result.isOKhasData()) { // Note, given above logic, could exist, but stale
// return result.value;
// } else {
// return null;
public Result<List<DATA>> read(final TRANS trans, final Object ... objs) {
DAOGetter getter = new DAOGetter(trans,dao,objs);
return get(trans, keyFromObjs(objs),getter);
-// if(ld!=null) {
+// if (ld!=null) {
// return Result.ok(ld);//.emptyList(ld.isEmpty());
// }
// // Result Result if exists
-// if(getter.result==null) {
+// if (getter.result==null) {
// return Result.err(Status.ERR_NotFound, "No Cache or Lookup found on [%s]",dao.table());
// }
// return getter.result;
public Result<List<DATA>> read(final String key, final TRANS trans, final Object[] objs) {
DAOGetter getter = new DAOGetter(trans,dao,objs);
return get(trans, key, getter);
-// if(ld!=null) {
+// if (ld!=null) {
// return Result.ok(ld);//.emptyList(ld.isEmpty());
// }
// // Result Result if exists
-// if(getter.result==null) {
+// if (getter.result==null) {
// return Result.err(Status.ERR_NotFound, "No Cache or Lookup found on [%s]",dao.table());
// }
// return getter.result;
}
public Result<Void> update(TRANS trans, DATA data) {
Result<Void> d = dao.update(trans, data);
- if(d.status==Status.OK) {
+ if (d.status==Status.OK) {
add(data);
} else {
trans.error().log(d.errorString());
}
public Result<Void> delete(TRANS trans, DATA data, boolean reread) {
- if(reread) { // If reread, get from Cache, if possible, not DB exclusively
+ if (reread) { // If reread, get from Cache, if possible, not DB exclusively
Result<List<DATA>> rd = read(trans,data);
- if(rd.notOK()) {
+ if (rd.notOK()) {
return Result.err(rd);
// } else {
// trans.error().log(rd.errorString());
}
- if(rd.isEmpty()) {
+ if (rd.isEmpty()) {
data.invalidate(this);
return Result.err(Status.ERR_NotFound,"Not Found");
}
@Override
public void close(TRANS trans) {
- if(dao!=null) {
+ if (dao!=null) {
dao.close(trans);
}
}
}
public void invalidate(TRANS trans, DATA data) {
- if(info.touch(trans, dao.table(),data.invalidate(this)).notOK()) {
+ if (info.touch(trans, dao.table(),data.invalidate(this)).notOK()) {
trans.error().log("Cannot touch CacheInfo for Role");
}
}