UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'P7KHiWUWexgC0y+8YORs9pxga76YODugYo9Xiyeol4w=' 
WHERE 
  key_id = '9984e2c02d1fb113d26d2bf50b4bd95b8248e4ebb6e91ccb6b65c2c0ddee4aa7' 
  AND (
    token = 'P7KHiWUWexgC0y+8YORs9pxga76YODugYo9Xiyeol4w=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00044