Flushes the cache, saving all changes that were made.
()
| 188 | * Flushes the cache, saving all changes that were made. |
| 189 | */ |
| 190 | public synchronized void flush() { |
| 191 | modified.forEach(s -> { |
| 192 | Object val = cache.get(s); |
| 193 | Object[] objs = new Object[s.getParams().length + 1]; |
| 194 | objs[0] = val; |
| 195 | for (int i = 0; i < s.getParams().length; i++) { |
| 196 | objs[i + 1] = s.getParams()[i]; |
| 197 | } |
| 198 | sql.execute(updateQuery, objs); |
| 199 | }); |
| 200 | modified.clear(); |
| 201 | } |
| 202 | |
| 203 | /** |
| 204 | * Flushes a single value from the cache, saving changes that were made to it |