UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Xd6R9Xz8WM71U7X/hYmcPZDWQTgkk83d3sEJF1pKwRM=' 
WHERE 
  key_id = '77e903b9700f6313b66a0325c8e65269350148c30a52fafff57e9c4a7dbcb78a' 
  AND (
    token = 'Xd6R9Xz8WM71U7X/hYmcPZDWQTgkk83d3sEJF1pKwRM=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00037