UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = '6aZPr+UrciEbccgoO/ETECYvIp4jUfqr1VmbFFWK1+M=' 
WHERE 
  key_id = 'a4f7972d9d73844a55a9fde2cab2147b26040a2e145e6e9e370ab497adab0f07' 
  AND (
    token = '6aZPr+UrciEbccgoO/ETECYvIp4jUfqr1VmbFFWK1+M=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00024