Ejemplo n.º 1
0
 private HTTPResponse getImpl(Connection connection, final Key key) {
   PreparedStatement statement = null;
   try {
     statement = connection.prepareStatement("select * from response where uri = ? and vary = ?");
     statement.setString(1, key.getURI().toString());
     statement.setString(2, key.getVary().toJSON());
     ResultSet rs = statement.executeQuery();
     if (rs.next()) {
       CacheItemHolder holder = mapper.mapRow(rs, connection);
       return holder.getCacheItem().getResponse();
     }
   } catch (SQLException e) {
     throw new DataAccessException(e);
   } finally {
     JdbcUtil.close(statement);
   }
   return null;
 }
Ejemplo n.º 2
0
 @Override
 public CacheItem get(HTTPRequest request) {
   Connection connection = getConnection();
   PreparedStatement statement = null;
   try {
     statement = connection.prepareStatement("select * from response where uri = ?");
     statement.setString(1, request.getRequestURI().toString());
     ResultSet rs = statement.executeQuery();
     while (rs.next()) {
       CacheItemHolder holder = mapper.mapRow(rs, connection);
       if (holder.getVary().matches(request)) {
         return holder.getCacheItem();
       }
     }
   } catch (SQLException e) {
     throw new DataAccessException(e);
   } finally {
     JdbcUtil.close(statement);
   }
   return null;
 }