UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'A86TYpL+5tct+Oj3EiU6h3B1SCDuneopUu+eZftkiMc=' 
WHERE 
  key_id = 'da2a199a0c1df55c8bb6066a711cda9880749557af093165d546cef01c8ca7fb' 
  AND (
    token = 'A86TYpL+5tct+Oj3EiU6h3B1SCDuneopUu+eZftkiMc=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00032