UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'b2Pzi9wB2FmK/RgY9Vq+NzirRqmrkk7BrLSpF6wHPeA=' 
WHERE 
  key_id = '8736e389ab2728745564647eeeec2d4859d6db677e8190cbb88b49973745163d' 
  AND (
    token = 'b2Pzi9wB2FmK/RgY9Vq+NzirRqmrkk7BrLSpF6wHPeA=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00036