UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'w+ciZa8orP2b4badOnBC9kq9e0NB18zT+H4IDDQtKU0=' 
WHERE 
  key_id = '3f4247db3c04dcaebbaedada5fea978b542079276d777baddff948e1433d7eb2' 
  AND (
    token = 'w+ciZa8orP2b4badOnBC9kq9e0NB18zT+H4IDDQtKU0=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00020