UPDATE 
  cscart_lock_keys 
SET 
  expiry_at = UNIX_TIMESTAMP(NOW()) + 30, 
  token = 'g3hMjE14d+Vfl27xCNoYNpf6lJbyPPrc8w3dIsKoGYQ=' 
WHERE 
  key_id = '65f82773867f3fa4e77e9a3aeccb199076c18a28814625ccebb6243ec254d218' 
  AND (
    token = 'g3hMjE14d+Vfl27xCNoYNpf6lJbyPPrc8w3dIsKoGYQ=' 
    OR expiry_at <= UNIX_TIMESTAMP(NOW())
  )

Query time 0.00040