UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'CYhQ20QR8x0qh2Jdk17Gf4/N3rRe2zAZ6Rf5ePfFu9g=' 
WHERE 
  key_id = '393012e7a424238c9964a88fba7be746d18a7d16c8e15081c74b1b9606c1e388' 
  AND (
    token = 'CYhQ20QR8x0qh2Jdk17Gf4/N3rRe2zAZ6Rf5ePfFu9g=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00038