UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'G5dTGi72CBeptNvxVGz20Ss6Y0ZAk2bCgDy1wKJ+za0=' 
WHERE 
  key_id = 'b50096a9ac041f953cd3eecabc799e3678de1f60b6fd003f394b068bdc1519d7' 
  AND (
    token = 'G5dTGi72CBeptNvxVGz20Ss6Y0ZAk2bCgDy1wKJ+za0=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00038