UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'Gvo6Gi8BccFacPdPoix9NSByjVhs29PL6S9D60E0CnY=' 
WHERE 
  key_id = '4a9b22634a0df40a23648c8ca12ed7ffe1063a555de3d1731648e6d198393f21' 
  AND (
    token = 'Gvo6Gi8BccFacPdPoix9NSByjVhs29PL6S9D60E0CnY=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00027